BP_Friends_Friendship::check_is_friend( int $initiator_userid, int $possible_friend_userid )

Check friendship status between two users.

Description

Note that ‘pending’ means that $initiator_userid has sent a friend request to $possible_friend_userid that has not yet been approved, while ‘awaiting_response’ is the other way around ($possible_friend_userid sent the initial request).

Parameters

$initiator_userid

(int) (Required) The ID of the user who is the initiator of the potential friendship/request.

$possible_friend_userid

(int) (Required) The ID of the user who is the recipient of the potential friendship/request.

Return

(string|false) $value The friendship status, from among 'not_friends', 'is_friend', 'pending', and 'awaiting_response'.

Source

File: bp-friends/classes/class-bp-friends-friendship.php

	public static function check_is_friend( $initiator_userid, $possible_friend_userid ) {
		global $wpdb;

		if ( empty( $initiator_userid ) || empty( $possible_friend_userid ) ) {
			return false;
		}

		// Can't friend yourself.
		if ( $initiator_userid == $possible_friend_userid ) {
			return 'not_friends';
		}

		BP_Friends_Friendship::update_bp_friends_cache( $initiator_userid, $possible_friend_userid );

		return bp_core_get_incremented_cache( $initiator_userid . ':' . $possible_friend_userid, 'bp_friends' );
	}

Changelog

Changelog
Version Description
BuddyPress 1.0.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.