Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Let members change their first_name and last_name in WP user's profile


mgpix
Participant

@mgpix

Ok, I eventually found a workaround.

The below code will update firstname and lastname fields in the BP member profile upon user registration :


add_action('user_register', 'my_user_register');
function my_user_register($user_id)
{
if ( function_exists( 'xprofile_set_field_data' ) ) {
$firstname = get_usermeta( $user_id, 'first_name' );
$lastname = get_usermeta( $user_id, 'last_name' );
xprofile_set_field_data( 'firstname', $user_id, $firstname );
xprofile_set_field_data( 'lastname', $user_id, $lastname );
}
}

Skip to toolbar