Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I check if a particular profile is a friend’s?

  • Avatar of Ishimwe
    Ishimwe
    Participant

    @ishimwe

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    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;
    }

    Avatar of wellrootedmedia
    wellrootedmedia
    Participant

    @wellrootedmedia

    I get this error, “Fatal error: Call to undefined function friends_check_friendship()”. Did this change or something, because it seems that I can’t set the variable to “friends_check_friendship”.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.