bp_friends_filter_user_query_populate_extras

Filter BP_User_Query::populate_extras to add confirmed friendship status.

Description

bp_friends_filter_user_query_populate_extras( (BP_User_Query) BP_User_Query $user_query, (string) $user_ids_sql ); 

Each member in the user query is checked for confirmed friendship status against the logged-in user.

Parameters (2)

0. $user_query (BP_User_Query) => BP_User_Query $user_query
The BP_User_Query object.
1. $user_ids_sql (string)
Comma-separated list of user IDs to fetch extra data for, as determined by BP_User_Query.

Usage

  1. if ( !function_exists( 'bp_friends_filter_user_query_populate_extras' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-filters.php'; 
  3.  
  4. // The BP_User_Query object. 
  5. $user_query = BP_User_Query $user_query; 
  6.  
  7. // Comma-separated list of user IDs to fetch extra 
  8. // data for, as determined by BP_User_Query. 
  9. $user_ids_sql = ''; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bp_friends_filter_user_query_populate_extras($user_query, $user_ids_sql); 
  13.  

Defined (1)

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

/bp-friends/bp-friends-filters.php  
  1. function bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query, $user_ids_sql ) { 
  2. global $wpdb; 
  3.  
  4. // Stop if user isn't logged in. 
  5. if ( ! $user_id = bp_loggedin_user_id() ) { 
  6. return; 
  7.  
  8. $maybe_friend_ids = wp_parse_id_list( $user_ids_sql ); 
  9.  
  10. foreach ( $maybe_friend_ids as $friend_id ) { 
  11. $status = BP_Friends_Friendship::check_is_friend( $user_id, $friend_id ); 
  12. $user_query->results[ $friend_id ]->friendship_status = $status; 
  13. if ( 'is_friend' == $status ) { 
  14. $user_query->results[ $friend_id ]->is_friend = 1; 
  15.