bbp_user_has_profile

Does a user have a profile for the current site.

Description

(boolean) bbp_user_has_profile( (int) $user_id = 0 ); 

Returns (boolean)

Whether or not the user has a profile on this blog_id

Parameters (1)

0. $user_id — Optional. (int)
User ID to check

Usage

  1. if ( !function_exists( 'bbp_user_has_profile' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/capabilities.php'; 
  3.  
  4. // User ID to check 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_user_has_profile($user_id); 
  9.  

Defined (1)

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

/includes/users/capabilities.php  
  1. function bbp_user_has_profile( $user_id = 0 ) { 
  2.  
  3. // Assume every user has a profile 
  4. $retval = true; 
  5.  
  6. // Validate user ID, default to displayed or current user 
  7. $user_id = bbp_get_user_id( $user_id, true, true ); 
  8.  
  9. // Try to get this user's data 
  10. $user = get_userdata( $user_id ); 
  11.  
  12. // No user found, return false 
  13. if ( empty( $user ) ) { 
  14. $retval = false; 
  15.  
  16. // User is inactive, and current user is not a keymaster 
  17. } elseif ( ! bbp_is_user_keymaster() && bbp_is_user_inactive( $user->ID ) ) { 
  18. $retval = false; 
  19.  
  20. // Filter and return 
  21. return (bool) apply_filters( 'bbp_show_user_profile', $retval, $user_id );