Plugin: BuddyPress Followers

Join this plugin group to follow comments, support topics and reviews.

Display Followers/Following Count (11 posts)

Started 1 year, 8 months ago by: iintense

  • Profile picture of iintense iintense said 1 year, 8 months ago:

    Is there a way I could display the users followers or following count outside of a widget?

  • function follow_deleted( $user_id ) {
    global $wpdb, $bp;

    $wpdb->query( $wpdb->prepare( “DELETE FROM {$bp->follow->table_name} WHERE leader_id = %d”, user_id ) );
    $wpdb->query( $wpdb->prepare( “DELETE FROM {$bp->follow->table_name} WHERE follower_id = %d”, user_id ) );

    }

    add_action( ‘wpmu_delete_user’, ‘follow_deleted’ );
    add_action( ‘delete_user’, ‘follow_deleted’ );
    add_action( ‘make_spam_user’, ‘follow_deleted’ )

  • Profile picture of ryanITLab ryanITLab said 1 year, 2 months ago:

    I am trying to do the same thing as @iintense
    @phartes – I don’t understand your reply

    I am just trying to get a list of the names of the people a user is following / is followed by

  • Profile picture of drebabels drebabels said 1 year, 2 months ago:

    Basically what you need to do is create a new BP members loop using bp_has_members(), and filter it so that it returns only the followers / following members. Below is what I am using on my site to return user following avatars.

    <?php if ( bp_has_members( 'type=random&per_page=10&include=' . bp_get_following_ids() ) ) : ?>
    	<div id="following" class="widget">
    
    		<?php 
    
    		echo '<h2 class="widgettitle">Following <span class="count">'.$counts['following'].'</span></h2>';
    
    		?>
    
    		<ul id="following-list" class="item-list">
    		<?php while ( bp_members() ) : bp_the_member(); ?>
    
    			<li>
    				<div class="item-avatar">
    					<a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>">
    						<?php bp_member_avatar('type=full&width=100&height=100') ?>
    					</a>
    				</div>
    
    				<!-- <?php do_action( 'bp_following_list_item' ) ?> -->
    
    			</li>
    
    		<?php endwhile; ?>
    		</ul>
    	</div>
    	<?php else: ?>
    	<div class="widget">
    		<div id="message" class="info">
    			<p><?php _e( "Sorry, this member has no following.", 'buddypress' ) ?></p>
    		</div>
    	</div>
    <?php endif; ?>
  • Profile picture of Henry Henry said 9 months ago:

    @drebabels could you walk me through which files to edit etc?

  • Profile picture of drebabels drebabels said 9 months ago:

    @henry the code should go into one of your template files (i.e. if you want the followers to appear in your sidebar then you should add the code to sidebar.php). This Buddypress Follower Loop work the same way as Wordpress ones do.

  • Profile picture of drebabels drebabels said 9 months ago:

    @henrypwmoulton the code should go into one of your template files (i.e. if you want the followers to appear in your sidebar then you should add the code to sidebar.php). This Buddypress Follower Loop work the same way as Wordpress ones do.

  • Profile picture of Henry Henry said 9 months ago:

    @drebabels, on your site where exactly do you use that on your site?

  • Profile picture of alatrawlo alatrawlo said 5 months, 1 week ago:

    It is not possible for civilization to flow backward while there is youth in the world

  • Profile picture of siwangnviges siwangnviges said 5 months, 1 week ago:

    The very first law in advertising is to avoid the concrete promise and cultivate the delightfully vague :) )

  • Profile picture of matiou34 matiou34 said 4 months ago:

    @drebabels Hello !
    Everything works well but I can’t get the number of followers or following…
    Is there something wrong ?

    Thanks for your help !