bbp_get_user_display_role

Return a user's main role for display.

Description

(string) bbp_get_user_display_role( (int) $user_id = 0 ); 

Returns (string)

Parameters (1)

0. $user_id — Optional. (int)
The user id.

Usage

  1. if ( !function_exists( 'bbp_get_user_display_role' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/template.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_user_display_role($user_id); 
  9.  

Defined (1)

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

/includes/users/template.php  
  1. function bbp_get_user_display_role( $user_id = 0 ) { 
  2.  
  3. // Validate user id 
  4. $user_id = bbp_get_user_id( $user_id ); 
  5.  
  6. // User is not registered 
  7. if ( empty( $user_id ) ) { 
  8. $role = __( 'Guest', bbpress ); 
  9.  
  10. // User is not active 
  11. } elseif ( bbp_is_user_inactive( $user_id ) ) { 
  12. $role = __( 'Inactive', bbpress ); 
  13.  
  14. // User have a role 
  15. } else { 
  16. $role_id = bbp_get_user_role( $user_id ); 
  17. $role = bbp_get_dynamic_role_name( $role_id ); 
  18.  
  19. // No role found so default to generic "Member" 
  20. if ( empty( $role ) ) { 
  21. $role = __( 'Member', bbpress ); 
  22.  
  23. return apply_filters( 'bbp_get_user_display_role', $role, $user_id );