bp_core_get_user_displayname

Fetch the display name for a user.

Description

(string|bool) bp_core_get_user_displayname( (string) $user_id_or_username ); 

Returns (string|bool)

The display name for the user in question, or false if user not found.

Parameters (1)

0. $user_id_or_username (string)
The user id or username.

Usage

  1. if ( !function_exists( 'bp_core_get_user_displayname' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // The user id or username. 
  5. $user_id_or_username = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_get_user_displayname($user_id_or_username); 
  9.  

Defined (1)

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

/bp-members/bp-members-functions.php  
  1. function bp_core_get_user_displayname( $user_id_or_username ) { 
  2. if ( empty( $user_id_or_username ) ) { 
  3. return false; 
  4.  
  5. if ( ! is_numeric( $user_id_or_username ) ) { 
  6. $user_id = bp_core_get_userid( $user_id_or_username ); 
  7. } else { 
  8. $user_id = $user_id_or_username; 
  9.  
  10. if ( empty( $user_id ) ) { 
  11. return false; 
  12.  
  13. $display_names = bp_core_get_user_displaynames( array( $user_id ) ); 
  14.  
  15. if ( ! isset( $display_names[ $user_id ] ) ) { 
  16. $fullname = false; 
  17. } else { 
  18. $fullname = $display_names[ $user_id ]; 
  19.  
  20. /** 
  21. * Filters the display name for the passed in user. 
  22. * @since 1.0.1 
  23. * @param string $fullname Display name for the user. 
  24. * @param int $user_id ID of the user to check. 
  25. */ 
  26. return apply_filters( 'bp_core_get_user_displayname', $fullname, $user_id );