bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query, string $user_ids_sql )

Filter BP_User_Query::populate_extras to add confirmed friendship status.

Description Description

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

Top ↑

Parameters Parameters


(BP_User_Query) (Required) The BP_User_Query object.


(string) (Required) Comma-separated list of user IDs to fetch extra data for, as determined by BP_User_Query.

Source Source

File: bp-friends/bp-friends-filters.php

function bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query, $user_ids_sql ) {
	global $wpdb;

	// Stop if user isn't logged in.
	if ( ! $user_id = bp_loggedin_user_id() ) {

	$maybe_friend_ids = wp_parse_id_list( $user_ids_sql );

	// Bulk prepare the friendship cache.
	BP_Friends_Friendship::update_bp_friends_cache( $user_id, $maybe_friend_ids );

	foreach ( $maybe_friend_ids as $friend_id ) {
		$status = BP_Friends_Friendship::check_is_friend( $user_id, $friend_id );
		$user_query->results[ $friend_id ]->friendship_status = $status;
		if ( 'is_friend' == $status ) {
			$user_query->results[ $friend_id ]->is_friend = 1;


Top ↑

Changelog Changelog

Version Description
1.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.