Tagged: Remove "add friend"
Hi,
I want to restrict my users from sending friend request to my admins. So, I want to remove the “add friend” button from admins’ profile.
Here I see a similar topic though, could not modify to satisfy my case. (https://buddydev.com/support/forums/topic/remove-add-friend-button-for-member-type-on-members-pagemembers-loop/)I will be greatly helped, if someone can help me out.
Thank you,
Md Sadiqur RahmanHi,
Please use the following code in bp-custom.php/** * Disable add friends button fro admin users * * it is an example and not recommended. It can cause n extra queries due to capability checking on the members loop. * * @param $button * * @return mixed */ function buddydev_hide_admin_friends_button( $button ) { if( ! isset( $button['id'] ) || $button['id'] != 'not_friends' ) { return $button; } $user_id = absint( str_replace( 'friend-','', $button['link_id'] ) ); if ( ! $user_id ) { return $button ; } //we can check using is_super_admin( $user_id ) || user_can( $user_id, 'cap' ) if ( user_can( $user_id, 'manage_options' ) ) { $button['id'] = false; } return $button; } add_filter( 'bp_get_add_friend_button', 'buddydev_hide_admin_friends_button' );
Please do note that it will cause n extra queries on the members loop.
Regards
Brajesh
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘ [Resolved] Remove "add friend" button from admins' profile’ is closed to new replies.
This topic is: resolved