Tagged: buddypress, non-members, user roles
Hi,
I’d like to disable the Join Group Button and Add Friend Button for certain users with a particular role. So far I’ve been able to filter non members from the BuddyPress members. But I’d like to restrict users with certain roles from using certain features like joining groups and adding friends.
Regards,
EmmanuelHi Emmanuel,
Welcome to BuddyDev forums.It is doable and there can be multiple ways to do it. Are you comfortable with php code? If yes, I can guide in the right direction.
Thank you
BrajeshHi Emmanuel,
Here are some example code to show hiding the buttons for specific olesadd_filter( 'bp_get_group_join_button', 'custom_hide_joingroup_button'); function custom_hide_joingroup_button( $btn) { if ( ! current_user_can('manage_options' ) ) { unset( $btn['id'] );//unsetting id will fore BP_Button to not generate any content } return $btn; } add_filter( 'bp_get_add_friend_button', 'custom_hide_addfriend_button' ); function custom_hide_addfriend_button( $btn ) { if ( ! current_user_can('manage_options' ) ) { unset( $btn['id'] );//unsetting id will fore BP_Button to not generate any content } return $btn; }
Please take a look at this table to see which capability you may use.
Hope that it helps.
Here is the link to the table.
https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table
The topic ‘ [Resolved] Disable BuddyPress 'Join Group' and 'Add friend' based on user's role’ is closed to new replies.