bbp_get_user_nicename

Return a users nicename to the screen.

Description

(string) bbp_get_user_nicename( (int) $user_id = 0, (array) $args = array() ); 

Returns (string)

User nicename, maybe wrapped in before/after strings

Parameters (2)

0. $user_id — Optional. (int)
User ID whose nicename to get
1. $args — Optional. (array) => array()
Before|after|user_id|force

Usage

  1. if ( !function_exists( 'bbp_get_user_nicename' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/template.php'; 
  3.  
  4. // User ID whose nicename to get 
  5. $user_id = -1; 
  6.  
  7. // before|after|user_id|force 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_get_user_nicename($user_id, $args); 
  12.  

Defined (1)

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

/includes/users/template.php  
  1. function bbp_get_user_nicename( $user_id = 0, $args = array() ) { 
  2.  
  3. // Bail if no user ID passed 
  4. $user_id = bbp_get_user_id( $user_id ); 
  5. if ( empty( $user_id ) ) 
  6. return false; 
  7.  
  8. // Parse default arguments 
  9. $r = bbp_parse_args( $args, array( 
  10. 'user_id' => $user_id,  
  11. 'before' => '',  
  12. 'after' => '',  
  13. 'force' => '' 
  14. ), 'get_user_nicename' ); 
  15.  
  16. // Get the user data and nicename 
  17. if ( empty( $r['force'] ) ) { 
  18. $user = get_userdata( $user_id ); 
  19. $nicename = $user->user_nicename; 
  20.  
  21. // Force the nicename to something else 
  22. } else { 
  23. $nicename = (string) $r['force']; 
  24.  
  25. // Maybe wrap the nicename 
  26. $retval = !empty( $nicename ) ? ( $r['before'] . $nicename . $r['after'] ) : ''; 
  27.  
  28. // Filter and return 
  29. return (string) apply_filters( 'bbp_get_user_nicename', $retval, $user_id, $r );