Skip to:
Content
Pages
Categories
Search
Top
Bottom

Prevent subscribers from creating groups


  • billysgtr
    Participant

    @billysgtr

    Hi,

    I want to prevent subscribers from creating groups.

    I have created the bp-custom.php inside the plugins folder and I am trying to accomplish this, by using the following

    apply_filters( 'bp_user_can_create_groups', $can_create, $restricted );

    but I didn’t manage to solve that.

    I would appreciate if anyone could help here.
    Thank you in advance.

Viewing 2 replies - 1 through 2 (of 2 total)

  • Jonas
    Participant

    @jonaskjodt

    You could try something like this

    add_filter( 'bp_user_can_create_groups', 'create_groups_hide_for_roles' );
    function create_groups_hide_for_roles($can)
    	{
    	$user = wp_get_current_user();
    	$banned_roles = array(
    		'subscriber',
    		'editor' // fill in the roles who can't make groups
    	);
    	if (array_intersect($banned_roles, $user->roles))
    	{
    		return false;
    
    	} else {
    
    		return $can;
    	}
    }

    Edit the roles in the array as you see fit.


    billysgtr
    Participant

    @billysgtr

    Awesome, thanks @Jonas!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar