Skip to:
Content
Pages
Categories
Search
Top
Bottom

Friends only shortcode


  • phos flip
    Participant

    @wamoma

    Merry Xmas!!

    I’d like to display some information submitted via a form and displayed on a custom tab. Some of this information should be viewable only by friends.

    Is there an existing shortcode to make fields/data friends only or if not could somebody point me in the direction for how I could go about creating a function to do so?

Viewing 1 replies (of 1 total)

  • phos flip
    Participant

    @wamoma

    <tumbleweed> 🙂

    I figured out a solution. Probably not at all elegant but in case it’s of use the following creates a shortcode that can be used to show data to friends only using [isfriend]data[/isfriend]:

    function isfriend( $atts, $content = null ) {
    
    global $bp;
    $is_friend = friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id );
    $is_me = bp_is_my_profile();
    
    if($is_friend or $is_me) {
       return '<div class="right text">'.$content.'</div>';
    } 
    
    }
    
    add_shortcode("isfriend", "isfriend");
    
Viewing 1 replies (of 1 total)
  • The topic ‘Friends only shortcode’ is closed to new replies.
Skip to toolbar