bp_core_map_user_registration

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

Description

bp_core_map_user_registration( (int) $user_id ); 

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 (1)

0. $user_id (int)
ID of the user.

Usage

  1. if ( !function_exists( 'bp_core_map_user_registration' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // ID of the user. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_map_user_registration($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-members/bp-members-functions.php  
  1. function bp_core_map_user_registration( $user_id ) { 
  2.  
  3. // Only map data when the site admin is adding users, not on registration. 
  4. if ( ! is_admin() ) { 
  5. return false; 
  6.  
  7. // Add the user's fullname to Xprofile. 
  8. if ( bp_is_active( 'xprofile' ) ) { 
  9. $firstname = bp_get_user_meta( $user_id, 'first_name', true ); 
  10. $lastname = ' ' . bp_get_user_meta( $user_id, 'last_name', true ); 
  11. $name = $firstname . $lastname; 
  12.  
  13. if ( empty( $name ) || ' ' == $name ) { 
  14. $name = bp_get_user_meta( $user_id, 'nickname', true ); 
  15.  
  16. xprofile_set_field_data( 1, $user_id, $name );