
Description
Checks if two users are friends. This buddypress function is used to check the friendship status of two users. It returns the friendship status as a string.
friends_check_friendship_status($user_id, $possible_friend_id )
Parameters
The functions requires two WordPress user ids to calculate if both of them are friends or not. Both user ids are required.
- $user_id (Integer | Required)
- $possible_friend_id (Integer | Required)
Returns
This function returns the status in string format. The returned string will be one of the following values:
- is_friend (Both users are friends)
- not_friends (Not friends)
- pending ( $user_id has initiated friend request which is pending )
- awaiting_response ($user_id has received friend request from $possible_friend_id but still need to accept or reject it.)
Usage
1 2 3 4 5 6 7 |
/* * Retrieves friendship status between currently logged in user id and user whose profile is being viewed */ $user_id = get_current_user_id(); $possible_friend_id = bp_displayed_user_id(); $friendship_status = friends_check_friendship_status($user_id, $possible_friend_id); echo $friendship_status; |