bbp_get_reply_author_display_name

Return the author display_name of the reply.

Description

(string) bbp_get_reply_author_display_name( (int) $reply_id = 0 ); 

Returns (string)

Reply's author's display name

Parameters (1)

0. $reply_id — Optional. (int)
Reply id

Usage

  1. if ( !function_exists( 'bbp_get_reply_author_display_name' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
  3.  
  4. // Optional. Reply id 
  5. $reply_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_reply_author_display_name($reply_id); 
  9.  

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_author_display_name( $reply_id = 0 ) { 
  2. $reply_id = bbp_get_reply_id( $reply_id ); 
  3.  
  4. // User is not a guest 
  5. if ( !bbp_is_reply_anonymous( $reply_id ) ) { 
  6.  
  7. // Get the author ID 
  8. $author_id = bbp_get_reply_author_id( $reply_id ); 
  9.  
  10. // Try to get a display name 
  11. $author_name = get_the_author_meta( 'display_name', $author_id ); 
  12.  
  13. // Fall back to user login 
  14. if ( empty( $author_name ) ) { 
  15. $author_name = get_the_author_meta( 'user_login', $author_id ); 
  16.  
  17. // User does not have an account 
  18. } else { 
  19. $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); 
  20.  
  21. // If nothing could be found anywhere, use Anonymous 
  22. if ( empty( $author_name ) ) 
  23. $author_name = __( 'Anonymous', bbpress ); 
  24.  
  25. // Encode possible UTF8 display names 
  26. if ( seems_utf8( $author_name ) === false ) 
  27. $author_name = utf8_encode( $author_name ); 
  28.  
  29. return apply_filters( 'bbp_get_reply_author_display_name', $author_name, $reply_id );