| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | |
|---|
| 4 | Plugin Name: Restrict Group Creation |
|---|
| 5 | Plugin URI: http://simonwheatley.co.uk/wordpress/restrict-group-creation/ |
|---|
| 6 | Description: Stops anyone and everyone from creating groups. |
|---|
| 7 | Version: 1.0 |
|---|
| 8 | Author: Simon Wheatley |
|---|
| 9 | Author URI: http://www.simonwheatley.co.uk/ |
|---|
| 10 | |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | // Stop the creation of a group |
|---|
| 14 | function rgc_validate_creation( $allowed, $group_details ) { |
|---|
| 15 | // At this point one could check the capabilities of the user, the details of the |
|---|
| 16 | // group to be created, etc. |
|---|
| 17 | bp_core_add_message( 'Sorry, you are not allowed to create groups.', 'error' ); |
|---|
| 18 | return false; |
|---|
| 19 | } |
|---|
| 20 | add_filter( 'bp_allow_create_group', 'rgc_validate_creation', null, 2 ); |
|---|
| 21 | |
|---|
| 22 | // Remove the create group link, so people don't get confused. |
|---|
| 23 | function rgc_remove_create_group_link() { |
|---|
| 24 | global $bp; |
|---|
| 25 | // Again, at this point one could check the capabilities of the user, the details |
|---|
| 26 | // of the group to be created, etc. |
|---|
| 27 | bp_core_remove_subnav_item( $bp->groups->slug, 'create' ); |
|---|
| 28 | } |
|---|
| 29 | add_action( 'groups_setup_nav', 'rgc_remove_create_group_link', 15 ); |
|---|
| 30 | |
|---|
| 31 | // Put a notice on the Group Creation screen warning the user that group creation |
|---|
| 32 | // will not be possible. |
|---|
| 33 | function rgc_notify_no_group_creation( $data ) { |
|---|
| 34 | // Again, at this point one could check the capabilities of the user, the details |
|---|
| 35 | // of the group to be created, etc. |
|---|
| 36 | bp_core_add_message( 'Sorry, you are not allowed to create groups.', 'error' ); |
|---|
| 37 | return $data; |
|---|
| 38 | } |
|---|
| 39 | add_filter( 'bp_group_creation_stage_title', 'rgc_notify_no_group_creation' ); |
|---|
| 40 | |
|---|
| 41 | ?> |
|---|