Skip to:
Content
Pages
Categories
Search
Top
Bottom

Help with BuddyPress Friends Loop

  • @pollyplummer

    Member

    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)
  • @pollyplummer

    Member

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

    @djpaul

    Keymaster

    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();

    @pollyplummer

    Member

    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’] ) ) : ?>

    @apeatling

    Keymaster

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

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

    @pollyplummer

    Member

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

    @apeatling

    Keymaster

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

    @pollyplummer

    Member

    Ah, perfect. Thank you! :)

    @pollyplummer

    Member

    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!

    @pollyplummer

    Member

    @symm2112

    Participant

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

    @pollyplummer

    Member

    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.
Skip to toolbar