bp_friend_get_total_requests_count

Return the total friendship request count for a given user.

Description

(int) bp_friend_get_total_requests_count( (int) $user_id = 0 ); 

Returns (int)

Friend count.

Parameters (1)

0. $user_id — Optional. (int)
ID of the user whose requests are being counted. Default: ID of the logged-in user.

Usage

  1. if ( !function_exists( 'bp_friend_get_total_requests_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-template.php'; 
  3.  
  4. // ID of the user whose requests are being counted. 
  5. // Default: ID of the logged-in user. 
  6. $user_id = -1; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_friend_get_total_requests_count($user_id); 
  10.  

Defined (1)

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

/bp-friends/bp-friends-template.php  
  1. function bp_friend_get_total_requests_count( $user_id = 0 ) { 
  2. if ( empty( $user_id ) ) 
  3. $user_id = bp_loggedin_user_id(); 
  4.  
  5. /** 
  6. * Filters the total friendship request count for a given user. 
  7. * @since 1.2.0 
  8. * @since 2.6.0 Added the `$user_id` parameter. 
  9. * @param int $value Friendship request count. 
  10. * @param int $user_id ID of the queried user. 
  11. */ 
  12. return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ), $user_id );