bp_activity_get_user_mentionname

Determine a user's "mentionname", the name used for that user in @-mentions.

Description

(string) bp_activity_get_user_mentionname( (int|string) $user_id ); 

Returns (string)

$mentionname User name appropriate for @-mentions.

Parameters (1)

0. $user_id (int|string)
ID of the user to get @-mention name for.

Usage

  1. if ( !function_exists( 'bp_activity_get_user_mentionname' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // ID of the user to get @-mention name for. 
  5. $user_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_get_user_mentionname($user_id); 
  9.  

Defined (1)

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

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_get_user_mentionname( $user_id ) { 
  2. $mentionname = ''; 
  3.  
  4. $userdata = bp_core_get_core_userdata( $user_id ); 
  5.  
  6. if ( $userdata ) { 
  7. $mentionname = str_replace( ' ', '-', $userdata->user_login ); 
  8. } else { 
  9. $mentionname = $userdata->user_nicename; 
  10.  
  11. return $mentionname;