Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How do I check if a particular profile is a friend’s? (2 posts)

Started 1 year, 11 months ago by: Ishimwe

  • Profile picture of Ishimwe Ishimwe said 1 year, 11 months ago:

    I am building a site with custom profile display. I want to display some content (Wordpress posts) only if the current profile (on which it is being displayed) is that of a friend. In other words, if the viewer is not my friend, they shouldn’t see posts I published.
    I am assuming an if, else loop would do, but I don’t know the bp function for checking if the owner of current profile is my friend.

  • Profile picture of r-a-y r-a-y said 1 year, 11 months ago:

    Check out the friends_check_friendship() function in /bp-friends.php.

    The parameters are:
    friends_check_friendship( $user_id, $possible_friend_id )

    And it returns true if the person is a friend.

    Example:

    global $bp;

    $is_friend = friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id );

    if ( $is_friend ) {
    run your custom code;
    }