bp_user_can_create_groups()

Determine if the current logged in user can create groups.

Description

Return

(bool) True if user can create groups. False otherwise.

Source

File: bp-groups/bp-groups-template.php

5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
function bp_user_can_create_groups() {
 
    // Super admin can always create groups.
    if ( bp_current_user_can( 'bp_moderate' ) ) {
        return true;
    }
 
    // Get group creation option, default to 0 (allowed).
    $restricted = (int) bp_get_option( 'bp_restrict_group_creation', 0 );
 
    // Allow by default.
    $can_create = true;
 
    // Are regular users restricted?
    if ( $restricted ) {
        $can_create = false;
    }
 
    /**
     * Filters if the current logged in user can create groups.
     *
     * @since BuddyPress 1.5.0
     *
     * @param bool $can_create Whether the person can create groups.
     * @param int  $restricted Whether or not group creation is restricted.
     */
    return apply_filters( 'bp_user_can_create_groups', $can_create, $restricted );
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.