Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WPUM Add new profile field
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' );
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');
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 );
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
You can’t perform that action at this time.