How To Restrict BuddyPress Group Creation Based on User Roles and Capabilities

restrictedIs your BuddyPress group creation getting out of hand? Would you rather your users submit group requests to you for moderation and create them yourself? After doing a little bit of hunting on the BuddyPress forums, I stumbled across this custom plugin created by Simon Wheatley.

Here’s how you can use it to restrict BuddyPress group creation to admin only:

Step 1: Download the Restrict Group Creation plugin.

Step 2: FTP that file to your Plugins directory and activate. This will change it so that no users can create groups.

Step. 3: Add this code to each function to permit the admin to create groups:

if ( current_user_can( 'manage_options' ) )
return true;

So what’ you’ll have then for the first function will look something like this:

function rgc_validate_creation( $allowed, $group_details ) {
	// At this point one could check the capabilities of the user, the details of the
	// group to be created, etc.
	if ( current_user_can( 'manage_options' ) )
return true;
	bp_core_add_message( 'Sorry, you are not allowed to create groups.', 'error' );
	return false;
add_filter( 'bp_allow_create_group', 'rgc_validate_creation', null, 2 );

You’ll want to modify the other functions in that plugin to match – or you can download my modified version here. :)

You can also modify it so that other roles can create groups as well, based on their roles and capabilities. For example, if I wanted to make it so that only Admins and Editors are allowed to create groups, I might use:

if ( current_user_can( 'delete_others_posts' ) )
return true;

This offers you a great deal of flexibility in customizing group creation by checking the user’s capabilities. I hope this is helpful to those wanting to further customize their BuddyPress communities.

Comments (5)

  1. Happy Holidays. Thanks for this. I”m surfing around to find an article on pros/cons of Buddypress with a single blog and not allowing people to create full-blown blogs/websites.

    The solution here is perfect for the secondary issue of groups and forums.

    I’m looking for people to be able to post to their page (group or profile) without having a full blown website. I know, it’s not the idea behind MU, but is consistent with more user interaction within Buddypress. One of my major problems with ning sites is the clutter that comes from multiple unmaintained, poor quality posts/blogs. Having a full blown site without moderation makes this even worse. Any ideas out there for this?

    I know I could hack something up where groups and individuals get a “category” in the wp_posts table that only shows on their “pages” with limited access/posting rights, but I’m worried about the size/speed hit to the posts table. Of course if I allow blogs to everyone, that means dedicated server expense here I come.

  2. Hello Sarah.
    I’ve been looking exactly for this kind of plugin for a project.
    I’ve installed both your version and the original version of this plugin, and still a normal member has the possibility to create a group.
    I’m using the latest version of BuddyPress. Could this be the reason?

  3. Thanks for the tips!

    I’m wondering if you know how I might restrict buddypress group creation based on user roles rather than capabilities?

    So, for example, I want to create a user role called “package 1″ and restrict that user to be able to create only 5 groups
    – versus –
    “package 2″ and restrict that user to be able to create 10 groups.

    Any ideas?