Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How to Create Add Friend Link with no Button


  • jstallard
    Participant

    @jstallard

    I’ve created a custom template for my members loop and want to display members in a table – http://webhive.com.au/members-by-area/.

    All good until I get to the Add Friend link, which is displayed as a button and wrapped in divs so that it displays above the table, rather than against each member entry. (You can’t see the Add Friend buttons unless you’re logged into my site.)

    How do I generate an Add Friend link (which becomes an Unfriend link if they’re already a friend), without the button? I want exactly the same functionality without the button’s html and css.

    Thanks!
    Jackie

Viewing 1 replies (of 1 total)

  • jstallard
    Participant

    @jstallard

    Sorry, that didn’t make sense 🙂 The problem wasn’t the divs. It was that the button function outputs straight to the screen, rather than into a variable. Problem solved!

    Fixed it by putting this in my theme’s function.php:

    function add_friend_button() {
         global $members_template;
     
        if ( !isset( $members_template->member->is_friend ) || null === $members_template->member->is_friend )
             $friend_status = 'not_friends';
         else
             $friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend';
     
         return bp_get_add_friend_button( $members_template->member->id, $friend_status );
     }

    And then called it from my modified template:
    $html.= add_friend_button();

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] How to Create Add Friend Link with no Button’ is closed to new replies.
Skip to toolbar