Skip to:
Content
Pages
Categories
Search
Top
Bottom

Help with BuddyPress Friends Loop

  • Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    I’m trying to output a modified version of the friends loop on the homepage … but I am getting the error: bp_has_friendships is not defined. I have no problems putting a modified members or groups loop together. I’m using BP 1.2 and WP single user 2.9.1 Is there something extra I need to include in order to get this working?

    <?php if ( bp_has_friendships('type=active&per_page=6&max=50&user_id=' . bp_loggedin_user_id() ) ) : ?>

    <div class="avatar-block">

    <?php while ( bp_user_friendships() ) : bp_the_friendship(); ?>

    <li class="vcard">

    <div class="item-avatar">

    "><?php bp_friend_avatar_thumb() ?>

    </div>

    <?php endwhile; ?>

    </div>

    <?php else: ?>

    You have no friends.

    <?php echo ""; ?>

    <?php endif; ?>

Viewing 11 replies - 1 through 11 (of 11 total)
  • Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    Ok so that middle part of the code with the avatar section didn’t paste in correctly, but you get the idea. …

    Profile photo of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    bp_has_friendships was removed in BP 1.2 and put into the backwards compatibility update. Try something like:

    if ( bp_has_members( ‘user_id=’ . $user_id . ‘&type=alphabetical&per_page=0′ ) ) {

    while ( bp_members() ) : bp_the_member();

    Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    user_id=’ . $user_id . ‘&type=alphabetical&per_page=0′ doesn’t seem to filter it to only friends of that user … looks like it’s posting random members. Not sure what I’m doing wrong since I get no errors.

    Code:
    <?php if ( bp_has_members( ‘user_id=’ . $user_id . ‘&type=alphabetical&per_page=0′ . $instance[‘max_members’] ) ) : ?>

    Profile photo of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    Try hardcoding with a user_id to begin with to see if that works:

    <?php if ( bp_has_members( 'user_id=1' ) ) : ?>

    Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    Yes hardcoding works, but I am making a “My Friends” widget and I want to show the logged in user’s friends.

    Profile photo of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    <?php if ( bp_has_members( 'user_id=' . bp_loggedin_user_id() ) ) : ?>

    Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    Ah, perfect. Thank you! :)

    Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    Ok so I wrote a cute little widget for this so it’s easy to use. It’s my first plugin, so please be nice ;) Let me know if there’s anything with how it’s written. I’m sending it through the “Submit a Plugin” section in the BP repository. Thanks for the help!

    Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    Profile photo of Symm2112
    symm2112
    Participant

    @symm2112

    That’s a really great plugin Sarah and I really enjoy your posts and find them very informative. Keep up the good work!

    Profile photo of Sarah Gooding
    Sarah Gooding
    Participant

    @pollyplummer

    Thanks! Glad you find it useful! :)

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Help with BuddyPress Friends Loop’ is closed to new replies.