Last active
September 17, 2015 15:30
-
-
Save alessandrotesoro/65dde15ee693f1d67d8f to your computer and use it in GitHub Desktop.
WPUM Add new profile field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpum_add_field_to_edit_profile( $fields ) { | |
$meta_value = get_user_meta( get_current_user_id(), 'my_field', true ); | |
$fields[ 'my_field' ] = array( | |
'label' => 'My Field', | |
'type' => 'text', | |
'required' => false, | |
'placeholder' => '', | |
'priority' => 9999, | |
'value' => $meta_value | |
); | |
return $fields; | |
} | |
add_filter( 'wpum_get_account_fields', 'wpum_add_field_to_edit_profile' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpum_add_registration_fields( $fields ) { | |
$fields[ 'my_field' ] = array( | |
'label' => 'My Field', | |
'type' => 'text', | |
'required' => false, | |
'placeholder' => '', | |
'priority' => 9999, | |
); | |
return $fields; | |
} | |
add_filter('wpum_get_registration_fields','wpum_add_registration_fields'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpum_save_my_field( $user_id, $values ) { | |
$submitted_value = $values['register']['my_field']; | |
update_user_meta( $user_id, 'my_field', $submitted_value ); | |
} | |
add_action( 'wpum/form/register/success', 'wpum_save_my_field', 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpum_save_my_field_on_edit( $user_data, $values, $user_id ) { | |
$submitted_value = $values['profile']['my_field']; | |
update_user_meta( $user_id, 'my_field', $submitted_value ); | |
} | |
add_action( 'wpum_after_user_update', 'wpum_save_my_field_on_edit', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment