Hi Brajesh,
As it appears you are the only one that is doing anything with the follow plugin by R-A-Y at all I thought I would ask you this. I am using the Youzify (Youzer) plugin and the FOLLOW plugin seems to work well with it. I would like to display a top list of my members based on the amount of followers that they have. Would this be hard to code?Thanks
Hi Milo,
Thank you for the question.The BuddyPress followe does not seem to provide the functionality for top followed users. you may use following code for the same.
/** * returns n number of top followed users. * * @param int $count number of entries requested. * * @return array */ function buddydev_get_top_followed_users( $count = 5 ) { global $wpdb; $bp = buddypress(); return $wpdb->get_col( $wpdb->prepare( "SELECT leader_id, COUNT( leader_id ) as follow_count FROM {$bp->follow->table_name} WHERE follow_type = %s GROUP BY leader_id ORDER BY follow_count DESC LIMIT 0, %d", '', $count ) ); }
It will give you an array of user ids ordered by their following count. You can iterate and list as you need. It will be available as a shortcode/widget in our future release.
Regards
BrajeshHi Milo,
Thank you for the kind words.Regards
BrajeshHi Brajesh,
I tried to make my own shortcode with this but I must have done something wrong. When I run the following code it simply returns the word… Aray … on the page and nothing else.
I added this code to my functions file…
/** * returns n number of top followed users. * * @param int $count number of entries requested. * * @return array **/ function buddydev_get_top_followed_users( $count = 100 ) { global $wpdb; $bp = buddypress(); return $wpdb->get_col( $wpdb->prepare( "SELECT leader_id, COUNT( leader_id ) as follow_count FROM {$bp->follow->table_name} WHERE follow_type = %s GROUP BY leader_id ORDER BY follow_count DESC LIMIT 0, %d", '', $count ) ); } add_shortcode('top_followers', 'buddydev_get_top_followed_users');
I used this shortcode..
[top_followers]
Hey Brajesh, how can use this shortcode to only show total follower count from the current user?
The topic ‘ [Resolved] Display Buddypress users by amount of Followers’ is closed to new replies.