Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to restrict group creation

  • @youmin

    Participant

    How to restrict group creating ability to certain member_type.

    If I am having 3 member types , I want to restrict one of the member_type to create group and allow rest of two to create.

Viewing 1 replies (of 1 total)
  • @youmin

    Participant

    Firstly is have set 3 members type using member_type() function . then I set the roles
    Using Henry’s solution
    I.e

    
     add_role(
        'student',
        __( 'Student' ),
        array(
            'read'         => true,  // true allows this capability
            'edit_posts'   => true,
            'delete_posts' => false, // Use false to explicitly 
        )
    
    ); 

    Then by using this function I tie these roles to wo roles.

    function youmin_set_role( $user_id, $member_type, $append ) {
        $userdata = array( 'ID' => $user_id, 'role' => $member_type );
        wp_update_user( $userdata );
    }
    add_action( 'bp_set_member_type', 'youmin_set_role', 10, 3 );

    But still every user is able to create group since by default wp role ‘subscriber’ is loading and buddypress user role let’s the subscriber to create group.

    So isn’t it possible to pass an array to above role function to restrict group creation ? Or any other code snippet ?

    Take a look at https://buddypress.org/support/topic/how-to-bp_set_member_type/

Viewing 1 replies (of 1 total)
  • The topic ‘How to restrict group creation’ is closed to new replies.
Skip to toolbar