bp_get_potential_friend_id

Return the ID of current user in the friend request loop.

Description

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

Returns (int)

ID of potential friend.

Parameters (1)

0. $user_id — Optional. (int)
If provided, the function will simply return this value.

Usage

  1. if ( !function_exists( 'bp_get_potential_friend_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-template.php'; 
  3.  
  4. // Optional. If provided, the function will simply 
  5. // return this value. 
  6. $user_id = -1; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_get_potential_friend_id($user_id); 
  10.  

Defined (1)

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

/bp-friends/bp-friends-template.php  
  1. function bp_get_potential_friend_id( $user_id = 0 ) { 
  2. global $friends_template; 
  3.  
  4. if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) ) 
  5. $user_id = $friends_template->friendship->friend->id; 
  6. elseif ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) ) 
  7. $user_id = bp_displayed_user_id(); 
  8.  
  9. /** 
  10. * Filters the ID of current user in the friend request loop. 
  11. * @since 1.2.10 
  12. * @param int $user_id ID of current user in the friend request loop. 
  13. */ 
  14. return apply_filters( 'bp_get_potential_friend_id', (int) $user_id );