Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'ld_dashboard_user_profile_fields', 'add_custom_profile_fields' );
- // Add custom field in the profile settings form.
- function add_custom_profile_fields($profile_fields) {
- $profile_fields['user_url'] = array(
- 'title' => esc_html__( 'Custom Field', 'ld-dashboard' ),
- 'tag' => 'input',
- 'type' => 'text',
- 'name' => 'custom_field',
- 'value' => get_user_meta( $current_user->ID, 'custom_field', true ),
- 'class' => 'form-url',
- )
- return $profile_fields;
- }
- add_action( 'ld_dashboard_save_user_profile_fields', 'update_custom_meta_field' );
- // Save custom field data.
- function update_custom_meta_field() {
- if ( isset( $_POST['custom_field'] ) && '' != $_POST['custom_field'] ) {
- update_user_meta( $current_user->ID, 'custom_field', sanitize_text_field( wp_unslash( $_POST['custom_field'] ) ) );
- } else {
- update_user_meta( $current_user->ID, 'custom_field', '' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement