Introduction
By default, BuddyBoss does not provide a built-in option to disable comments for individual users. You can achieve this by adding a small custom function to your active theme. This will prevent a specific user or user type from posting comments on activity feeds.
Custom Workaround
Before proceeding, make sure you have a complete site backup.
- Go to Appearance > Theme Editor in your WordPress admin dashboard.
- Under Select theme to edit, choose your active theme (preferably a BuddyBoss Child Theme), then click Select.
- From the Theme Files list, open Theme Functions (functions.php).
- Add the following code just before the closing PHP tag (?>):
add_filter(‘bp_nouveau_get_activity_entry_buttons’, ‘remove_comment_activity’);
function remove_comment_activity( $return ) {
$current_user_id = bbp_get_current_user_id();
$member_type = bp_get_member_type($current_user_id, true);
// Change 'individual' to the member type you want to restrict
if ( $member_type == 'individual' ) {
unset( $return['activity_conversation'] );
}
return $return;
}- Click Update File to save the changes.
This code removes the Comment button from the activity feed for users of a specific member type. You can adjust the ‘individual’ value to target the desired member type or modify the logic to target a specific user ID.
Troubleshooting and FAQs
Q: The comment button is still visible.
A: Make sure the member type matches the one specified in the code. You can debug by checking the user’s member type with bp_get_member_type($user_id, true).
Q: Does this prevent other users from commenting?
A: No. This only affects the users or member types specified in the code.
Q: Can I revert this change easily?
A: Yes. Remove or comment out the code from functions.php and save the file.