bp_get_friendship_requests( int $user_id )

Get a user’s friendship requests.


Description 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 Parameters

$user_id

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


Top ↑

Return Return

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


Top ↑

Source 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 friendship requests for a user.
	 *
	 * @since 1.2.0
	 * @since 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 );
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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