bp_get_friendship_requests( int $user_id )

Get a user’s connection requests.

Description

Note that we return a 0 if no pending requests are found. This is necessary because of the structure of the $include parameter in bp_has_members().

Parameters

$user_id

(Required) ID of the user whose requests are being retrieved. Defaults to displayed user.

Return

(array|int) An array of user IDs if found, or a 0 if none are found.

Source

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

function bp_get_friendship_requests( $user_id = 0 ) {
	if ( !$user_id ) {
		$user_id = bp_displayed_user_id();
	}

	if ( !$user_id ) {
		return 0;
	}

	$requests = friends_get_friendship_request_user_ids( $user_id );

	if ( !empty( $requests ) ) {
		$requests = implode( ',', (array) $requests );
	} else {
		$requests = 0;
	}

	/**
	 * Filters the total pending connection requests for a user.
	 *
	 * @since BuddyPress 1.2.0
	 * @since BuddyPress 2.6.0 Added the `$user_id` parameter.
	 *
	 * @param array|int $requests An array of user IDs if found, or a 0 if none are found.
	 * @param int       $user_id  ID of the queried user.
	 */
	return apply_filters( 'bp_get_friendship_requests', $requests, $user_id );
}

Changelog

Changelog
Version Description
BuddyPress 1.2.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.