1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Disable Comments for a Specific User

How to Disable Comments for a Specific User

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.

  1. Go to Appearance > Theme Editor in your WordPress admin dashboard.
  2. Under Select theme to edit, choose your active theme (preferably a BuddyBoss Child Theme), then click Select.
  3. From the Theme Files list, open Theme Functions (functions.php).
  4. 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;
}
  1. 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.

Note: Modifications are typically considered custom work, but we are making an exception in this case. Please review the BuddyBoss Support Policy.

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.

Was this article helpful?

Related Articles

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

  • This field is hidden when viewing the form
  • This field is for validation purposes and should be left unchanged.

To speak to our Agency consultant, fill in the form found at our Contact Page.

  • Get Started

    Enter your name and email address to get started with your project...

  • This field is for validation purposes and should be left unchanged.