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

December 23, 2009  | 
4 Comments

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.

Featured Plugin - Start your own Quora / StackOverflow / Yahoo Q&A site

It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more

Featured Plugin - Send beautiful html email newsletters, from WordPress!

Now there's no need to pay for a third party service to sign up, manage and send beautiful email newsletters to your subscriber base - this plugin has got the lot.
Find out more

Featured Plugin - Start Your Own Powerful Membership Site

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more

Featured Plugin - Add bottom corner (or anywhere else) chat to your site

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more

Featured Plugin - WordPress + Google Maps = Perfect

Simply insert google maps into posts, sidebars and pages - show directions, streetview, provide image overlays and do it all from a simple button and comprehensive widget.
Find out more

Featured Plugin - Host sites, get paid, just like WordPress.com

If you've ever wondered how you could offer a paid site management and hosting service, then this is the plugin for you. Offer a freemium or paid service, for any niche you like, it's powered Edublogs.org to success already!
Find out more

Featured Plugin - Open an Online Store with MarketPress

Out of all the WordPress ecommerce plugins available, this has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more

Featured Plugin - Every great SEO tweak you need, in one snazzy bundle

Fully integrated with the SEOMoz API, complete with automatic links, sitemaps and SEO optimization of your WordPress setup - this is the only plugin you need to help you rank your site number 1 on Google - nothing else compares.
Find out more

Featured Plugin - Easily integrate your WordPress site with Facebook

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

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

  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. Is there a way to restrict what gets posted on the Site Wide Activity widget?

  3. Thanks Sarah. Usefull.

  4. 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?

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting