# BuddyPress: Let Only Certain Roles Create Groups

> Restricts creating BuddyPress groups to the roles you choose, such as editors or paying members, while everyone can still join groups.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: buddypress, groups, roles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/buddypress-limit-group-creation/

## Code

```php
if ( ! function_exists( 'buddypress' ) ) {
    return;
}

// Roles allowed to create groups.
$wpide_bp_group_creators = array( 'editor', 'author' );

add_filter( 'bp_user_can_create_groups', function ( $can_create ) use ( $wpide_bp_group_creators ) {
    if ( ! is_user_logged_in() ) {
        return false;
    }

    if ( bp_current_user_can( 'bp_moderate' ) ) {
        return true;
    }

    return $can_create && (bool) array_intersect( $wpide_bp_group_creators, (array) wp_get_current_user()->roles );
} );
```

## Notes

Administrators can always create groups.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "BuddyPress: Let Only Certain Roles Create Groups" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
