bp_core_map_user_registration( int $user_id, bool $by_pass = false )

Map a user’s WP display name to the XProfile fullname field, if necessary.

Description

This only happens when a user is registered in wp-admin by an administrator; during normal registration, XProfile data is provided directly by the user.

Parameters

$user_id

(Required) ID of the user.

$by_pass

(Optional) ByPass is admin conditions.

Default value: false

Return

(bool)

Source

File: bp-members/bp-members-functions.php

2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
function bp_core_map_user_registration( $user_id ) {
 
    // Only map data when the site admin is adding users, not on registration.
    if ( ! is_admin() ) {
        return false;
    }
 
    // Add the user's fullname to Xprofile.
    if ( bp_is_active( 'xprofile' ) ) {
        $user = get_user_by( 'ID', $user_id );
        $firstname = bp_get_user_meta( $user_id, 'first_name', true );
        $lastname = bp_get_user_meta( $user_id, 'last_name', true );
        $nickname = $user->nickname;
 
        xprofile_set_field_data( bp_xprofile_firstname_field_id(), $user_id, $firstname );
        xprofile_set_field_data( bp_xprofile_lastname_field_id(),  $user_id, $lastname );
        xprofile_set_field_data( bp_xprofile_nickname_field_id(),  $user_id, $nickname );
 
        bp_xprofile_update_display_name( $user_id );
    }
}

Changelog

Changelog
Version Description
BuddyPress 1.2.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.