Buddypress Follower Plugin – Add Follow Link in other locations of your site

Posted by on Jan 5, 2012 in Buddypress | 0 comments

So you are looking to add additional Follow [user_name] links to your site?

Here is the function to use

<?php bp_follow_add_follow_button(array('leader_id'=>$displayed_userID, 'follower_id'=>$current_userID)) ?>


'leader_id'=>$displayed_userID, //this is the user id of current displayed user or current displayed users content, the followed
'follower_id'=>$current_userID  //this is the user id of the currently logged in user, the follower

Here is how I added the follow link to the activity stream.

Add two lines of code to the following template files:
If either of these files is missing then just copy them over from the default theme within the buddypress plugin folder.

This is the first line of code needed in both files, place it towards the top of the file, this is to make the buddypress object available in the file which is used to get the currently logged in user id.

<?php global $bp ?>

This line of code is used in the entry.php file. It utilizes a function to get the current entries user id.

<?php bp_follow_add_follow_button( array('leader_id'=>bp_get_activity_user_id(),'follower_id'=>$bp->loggedin_user->id)) ?>

This line of code is used in the comment.php file. It utilizes a function to get the current commenters user id.

<?php bp_follow_add_follow_button( array('leader_id'=>bp_get_activity_comment_user_id(),'follower_id'=>$bp->loggedin_user->id)) ?>

468 ad

Leave a Reply