BuddyDev

Disable BuddyPress group deletion by Non Site Admin

We received this question from Andre? How would you disable the BuddyPress group deletion by group admins and only allow site admins to delete a group? I believe, It may be helpful for others, so posting the code here

Disabling the delete option in the Group -> Manage screen:-

In the above code we check that we are on a group page and if the current user is not site admin, we remove the "delete" from the manage screen. Here is a screenshot:-

disable-buddypress-group-delete

The above code works but there is a problem. When you click on"Manage", It will give 404 as the redirect to the default sub nav is stopped. It seems there is a bug in BuddyPress that removes the screen callback. The solution, we reattach it again. Here is our final, updated code.

That's it. Put this code in your bp-custom.php and the future of all BuddyPress groups now depends on you, the site admin 🙂

6 Responses to Disable BuddyPress group deletion by Non Site Admin

  • Thank you very much! I'm going to link this to my Buddypress.org post and will be making a contribution to your site for this assistance. Best – Andre

  • Thanks ,
    Is it possible to delet all groups at once from backend i have test some plugin but none of them work
    Can you help me.

    • Hi Nabeel,
      My suggestions will be to take a backup of the database, Then truncating wp_bp_groups, wp_bp_groupmeta tables(prefixi wp may be different for you).
      After that, Please visit Dashboard->Tools->BuddyPress and check " Repair total groups count for each member." and repair it.

      That should be the fastest way to do it.

      Regards
      Brajesh

  • Hi,

    When i added this code to bp-custom.php file it works functionally(non admin users cannot delete the groups that they created) but at the top of the page it displays an error message that can be seen below. Can you help me? Thanks. (Note: It gives error in both PHP 5.6 and 7.2 versions.)

    • Hi Kerem,
      It happened due to a change in BuddyPress 3.0. I have updated the code to fix it.

      Regards
      Brajesh