Plugin Author
r-a-y
(@r-a-y)
Hi,
You can try adding your snippet to your theme’s functions.php or wp-content/plugins/bp-custom.php file.
Let me know if that works for you.
Thread Starter
inactive
(@nurdanucergmailcom)
Thanks for the quick response, and thank you for making your work and time available for the community.
Unfortunately it didn’t work from the functions.php or the bp-custom.php. It appears not to be reading the user capabilities and removes the buttons for everyone regardless of their caps.
Only when I edit the bp-follow-hooks.php in the plugin folder I got it to work properly:
function bp_follow_add_profile_follow_button() {
// customization to remove button from subscribers
if ( user_can( bp_displayed_user_id(), 'delete_posts' ) )
bp_follow_add_follow_button();
}
add_action( 'bp_member_header_actions', 'bp_follow_add_profile_follow_button' );
Do you think this needs to be wrapped in a function to work from elsewhere?
Your help is much appreciated.
Plugin Author
r-a-y
(@r-a-y)
Gotcha.
Thanks for posting your example.
What you need to do is remove the default button and run your function after BP Follow’s.
Try the following:
// remove the default BP Follow button
remove_action( 'bp_member_header_actions', 'bp_follow_add_profile_follow_button' );
// add custom button
function my_follow_add_profile_follow_button() {
// customization to remove button from subscribers
if ( user_can( bp_displayed_user_id(), 'delete_posts' ) )
bp_follow_add_follow_button();
}
add_action( 'bp_member_header_actions', 'my_follow_add_profile_follow_button' );
Thread Starter
inactive
(@nurdanucergmailcom)
Worked like a charm! Thank you!
But why couldn’t I get this one (member listing buttons) to work in the same way? It removed the button from all users:
// remove the default BP Follow button
remove_action( 'bp_directory_members_actions', 'bp_follow_add_listing_follow_button' );
// add custom button
function my_follow_add_listing_follow_button() {
global $members_template;
if ( $members_template->member->id == bp_loggedin_user_id() || ! user_can( bp_displayed_user_id(), 'delete_posts' ) )
return false;
bp_follow_add_follow_button( 'leader_id=' . $members_template->member->id );
}
add_action( 'bp_directory_members_actions', 'my_follow_add_listing_follow_button' );
Thread Starter
inactive
(@nurdanucergmailcom)
Silly me, I got it. Changing the conditional from:
! user_can( bp_displayed_user_id(), 'delete_posts' )
to
! user_can( $members_template->member->id, 'delete_posts' )
fixed the problem. 🙂