Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile editing kills last name


  • bumblebeegames
    Participant

    @bumblebeegames

    Hello, Buddies.
    I’ve got a weird issue here: I’m running a WP4.9.8 site running with BuddyPress 3.2.0. I’ve also setup a custom registration panel using “Membership Pro Ultimate WP”. This is correctly transferring the First and Last name from the registration screen into the WordPress default First Name and Last Name field.
    As I am primarilly using custom extended profile fields, I have written this script to fill in the extended fields as well:

    function update_extended_fields( $user_id ) {

    $user_info = get_userdata($user_id);
    $first_name = $user_info->first_name;
    $last_name = $user_info->last_name;
    $current_first = bp_get_profile_field_data( array( ‘field’ => ‘First Name’, ‘user_id’ => $user_id ) );
    $current_last = bp_get_profile_field_data( array( ‘field’ => ‘Last Name’, ‘user_id’ => $user_id ) );
    if ($current_first==””) {
    xprofile_set_field_data( “First Name”, $user_id, $first_name, $is_required = true );
    }
    if ($current_last==””) {
    xprofile_set_field_data( “Last Name”, $user_id, $last_name, $is_required = true );
    }
    wp_update_user( array( ‘ID’ => $user_id, ‘last_name’ => $last_name ) );
    //xprofile_set_field_data( “field_42”, $user_id, $company, $is_required = false );
    }
    add_action( ‘user_register’, ‘update_extended_fields’, 10, 1 );

    This is all working perfectly fine … until I edit the profile using buddypress on the frontend. After editing and saving it, the user’s WordPress Last Name gets lost. The extended field is still being displayed correctly.
    Any idea why this is happening?
    Thanks a lot!

  • You must be logged in to reply to this topic.
Skip to toolbar