<?php
/*

Plugin Name: Restrict Group Creation
Plugin URI: http://simonwheatley.co.uk/wordpress/restrict-group-creation/
Description: Stops anyone and everyone from creating groups.
Version: 1.0
Author: Simon Wheatley
Author URI: http://www.simonwheatley.co.uk/

*/

// Stop the creation of a group
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.
	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 );

// Remove the create group link, so people don't get confused.
function rgc_remove_create_group_link() {
	global $bp;
	// Again, at this point one could check the capabilities of the user, the details 
	// of the group to be created, etc.
	bp_core_remove_subnav_item( $bp->groups->slug, 'create' );
}
add_action( 'groups_setup_nav', 'rgc_remove_create_group_link', 15 );

// Put a notice on the Group Creation screen warning the user that group creation 
// will not be possible.
function rgc_notify_no_group_creation( $data ) {
	// Again, at this point one could check the capabilities of the user, the details 
	// of the group to be created, etc.
	bp_core_add_message( 'Sorry, you are not allowed to create groups.', 'error' );
	return $data;
}
add_filter( 'bp_group_creation_stage_title', 'rgc_notify_no_group_creation' );

?>