BP_Friends_Friendship::get_friendship_id( int $user_id, int $friend_id )

Get the ID of the friendship object, if any, between a pair of users.


Parameters Parameters

$user_id

(int) (Required) The ID of the first user.

$friend_id

(int) (Required) The ID of the second user.


Top ↑

Return Return

(int|null) The ID of the friendship object if found, otherwise null.


Source Source

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

	public static function get_friendship_id( $user_id, $friend_id ) {
		$friendship_id = null;

		// Can't friend yourself.
		if ( $user_id == $friend_id ) {
			return $friendship_id;
		}

		/*
		 * Find friendships where the possible_friend_userid is the
		 * initiator or friend.
		 */
		$args = array(
			'initiator_user_id' => $friend_id,
			'friend_user_id'    => $friend_id
		);
		$result = self::get_friendships( $user_id, $args, 'OR' );
		if ( $result ) {
			$friendship_id = current( $result )->id;
		}
		return $friendship_id;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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