ElggUser::isFriendOf PHP Method

isFriendOf() public method

Determines whether or not this user is another user's friend
public isFriendOf ( integer $user_guid ) : boolean
$user_guid integer The GUID of the user to check against
return boolean
    public function isFriendOf($user_guid)
    {
        return (bool) check_entity_relationship($user_guid, "friend", $this->guid);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * checks if the user can add a friend
  * @param ElggUser $user
  * @return boolean
  */
 public static function canAddFriend(ElggUser $user)
 {
     if (!isloggedin()) {
         return FALSE;
     }
     if ($user->getGUID() == get_loggedin_user()->getGuid()) {
         return FALSE;
     }
     if ($user->isFriendOf(get_loggedin_user()->getGuid())) {
         return FALSE;
     }
     return TRUE;
 }