bp_get_friend_ids

Get a comma-separated list of IDs of a user's friends.

Description

(string|bool) bp_get_friend_ids( (int) $user_id = 0 ); 

Returns (string|bool)

A comma-separated list of friend IDs if any are found, otherwise false.

Parameters (1)

0. $user_id — Optional. (int)
Default: the displayed user's ID, or the logged-in user's ID.

Usage

  1. if ( !function_exists( 'bp_get_friend_ids' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-template.php'; 
  3.  
  4. // Optional. Default: the displayed user's ID, or the 
  5. // logged-in user's ID. 
  6. $user_id = -1; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_get_friend_ids($user_id); 
  10.  

Defined (1)

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

/bp-friends/bp-friends-template.php  
  1. function bp_get_friend_ids( $user_id = 0 ) { 
  2.  
  3. if ( empty( $user_id ) ) 
  4.  
  5. $friend_ids = friends_get_friend_user_ids( $user_id ); 
  6.  
  7. if ( empty( $friend_ids ) ) 
  8. return false; 
  9.  
  10. return implode( ', ', friends_get_friend_user_ids( $user_id ) );