• Resolved issues.inc

    (@issuesinc)


    Great Plugin!

    Is there a way to display a list of users i’m following and that are following me on the sidebar without using a widget??

    I’m really new to php and couldn’t figure out how to do it by myself, we used the following code to display a list of friends,could this be modified to display following and followers?

    <?php if ( bp_has_members( 'type=newest&max=20&user_id=' . bp_loggedin_user_id() ) & is_user_logged_in() ) : ?>
    <?php while ( bp_members() ) : bp_the_member(); ?>
    [a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name();?>"]
    <?php bp_member_avatar( $avatar_args ) ?>
    [/a]
    <?php endwhile; ?>
    <?php else: ?>
    <?php _e( 'You dont have any friends yet', 'buddypress' ) ?>
    <?php endif; ?>

    Thank you!

    https://www.ads-software.com/plugins/buddypress-followers/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author r-a-y

    (@r-a-y)

    You might want to take a look at the widget code that comes with BP Follow as it does very similar functionality:
    https://github.com/r-a-y/buddypress-followers/blob/1.2.x/_inc/bp-follow-widgets.php#L36

    Modify that to your needs.

    Also, check out the wiki for more info:
    https://github.com/r-a-y/buddypress-followers/wiki

    Thread Starter issues.inc

    (@issuesinc)

    Thanks r-a-y!

    In case anyone else needs this, here’s the code

    Display Following:
    <?php if ( ! $following = bp_get_following_ids( array( 'user_id' => bp_loggedin_user_id() ) ) ) {
    return false;
    }
    if ( bp_has_members( array(
    'include' => $following,
    'max' => 30,
    'populate_extras' => false,
    ) ) ) : ?>
    <?php while ( bp_members() ) : bp_the_member(); ?>
    [a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name();?>"]
    <?php bp_member_avatar( $avatar_args ) ?>
    [/a]
    <?php endwhile; ?>
    <?php else: ?>
    <?php _e( 'You are not following anyone yet', 'buddypress' ) ?>
    <?php endif; ?>

    Display Followers:
    <?php if ( ! $follower = bp_get_follower_ids( array( 'user_id' => bp_loggedin_user_id() ) ) ) {
    return false;
    }
    if ( bp_has_members( array(
    'include' => $follower,
    'max' => 30,
    'populate_extras' => false,
    ) ) ) : ?>
    <?php while ( bp_members() ) : bp_the_member(); ?>
    [a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name();?>"]
    <?php bp_member_avatar( $avatar_args ) ?>
    [/a]
    <?php endwhile; ?>
    <?php else: ?>
    <?php _e( 'You dont have any followers yet', 'buddypress' ) ?>
    <?php endif; ?>

    Almost exactly what I was looking for.

    If someone wants to list the followers of the displayed user rather than the logged in user, simply replace bp_loggedin_user_id() with bp_displayed_user_id().

    So this:

    if ( ! $follower = bp_get_follower_ids( array( ‘user_id’ => bp_loggedin_user_id() ) ) ) {
    return false;
    }

    would be

    if ( ! $follower = bp_get_follower_ids( array( ‘user_id’ => bp_displayed_user_id() ) ) ) {
    return false;
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display Following and Followers on the sidebar’ is closed to new replies.