bbp_get_topic_author_email

Return the topic author email address.

Description

(string) bbp_get_topic_author_email( (int) $topic_id = 0 ); 

Returns (string)

Topic author email address

Parameters (1)

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

Usage

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

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_author_email( $topic_id = 0 ) { 
  2. $topic_id = bbp_get_topic_id( $topic_id ); 
  3.  
  4. // Not anonymous user 
  5. if ( !bbp_is_topic_anonymous( $topic_id ) ) { 
  6.  
  7. // Use topic author email address 
  8. $user_id = bbp_get_topic_author_id( $topic_id ); 
  9. $user = get_userdata( $user_id ); 
  10. $author_email = !empty( $user->user_email ) ? $user->user_email : ''; 
  11.  
  12. // Anonymous 
  13. } else { 
  14.  
  15. // Get email from post meta 
  16. $author_email = get_post_meta( $topic_id, '_bbp_anonymous_email', true ); 
  17.  
  18. // Sanity check for missing email address 
  19. if ( empty( $author_email ) ) { 
  20. $author_email = ''; 
  21.  
  22. return apply_filters( 'bbp_get_topic_author_email', $author_email, $topic_id );