bp_core_get_user_email

Return the email address for the user based on user ID.

Description

(string) bp_core_get_user_email( (int) $uid ); 

Returns (string)

The email for the matched user. Empty string if no user matched the $uid.

Parameters (1)

0. $uid (int)
User ID to check.

Usage

  1. if ( !function_exists( 'bp_core_get_user_email' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // User ID to check. 
  5. $uid = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_get_user_email($uid); 
  9.  

Defined (1)

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

/bp-members/bp-members-functions.php  
  1. function bp_core_get_user_email( $uid ) { 
  2.  
  3. if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) { 
  4.  
  5. // User exists. 
  6. $ud = bp_core_get_core_userdata( $uid ); 
  7. if ( ! empty( $ud ) ) { 
  8. $email = $ud->user_email; 
  9.  
  10. // User was deleted. 
  11. } else { 
  12. $email = ''; 
  13.  
  14. wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' ); 
  15.  
  16. /** 
  17. * Filters the user email for user based on user ID. 
  18. * @since 1.0.1 
  19. * @param string $email Email determined for the user. 
  20. */