Changeset 10037
- Timestamp:
- 08/07/2015 05:52:08 AM (9 years ago)
- Location:
- trunk/src/bp-friends
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-filters.php
r9995 r10037 35 35 $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids_sql} ) ) OR (initiator_user_id IN ( {$user_ids_sql} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id() ) ); 36 36 37 // Keep track of members that have a friendship status with the current user 38 $friend_user_ids = array(); 39 37 40 // The "friend" is the user ID in the pair who is *not* the logged in user 38 41 foreach ( (array) $friend_status as $fs ) { 39 42 $friend_id = bp_loggedin_user_id() == $fs->initiator_user_id ? $fs->friend_user_id : $fs->initiator_user_id; 43 $friend_user_ids[] = $friend_id; 40 44 41 45 if ( isset( $user_query->results[ $friend_id ] ) ) { … … 50 54 } 51 55 } 56 57 // The rest are not friends with the current user, so set status accordingly 58 $not_friends = array_diff( $user_query->user_ids, $friend_user_ids ); 59 foreach ( (array) $not_friends as $nf ) { 60 if ( bp_loggedin_user_id() == $nf ) { 61 continue; 62 } 63 $user_query->results[ $nf ]->friendship_status = 'not_friends'; 64 } 65 52 66 } 53 67 add_filter( 'bp_user_query_populate_extras', 'bp_friends_filter_user_query_populate_extras', 4, 2 ); -
trunk/src/bp-friends/bp-friends-functions.php
r9995 r10037 283 283 if ( isset( $members_template->member->friendship_status ) ) { 284 284 return $members_template->member->friendship_status; 285 286 // make sure that the friends BP_User_Query was registered before assuming287 // status as 'not_friends'288 } elseif ( has_filter( 'bp_user_query_populate_extras', 'bp_friends_filter_user_query_populate_extras' ) ) {289 return 'not_friends';290 285 } 291 286 }
Note: See TracChangeset
for help on using the changeset viewer.