[Buudypress] only allow to specific user to create a group in buddypress using membership2 pro

Hi there
i have one multi-site with a membership2 and buddypress installation
now i need to do some restriction for a user,
i need to allow only specific user to create a buddypress group ,
so let me explain what i need exactly
so user come to my site and i need to show a membership2 registration from and in a registration from i have a on drop down filed which is ask to user who you are 1)member 2) supporter
so if user select a member from drop down during registration process
so user only able to see the group or join the group and if user select a supporter so then user able to create a buddypress group
is this make a sense..?
Thanks in advance

  • Dimitris
    • Support Star

    Hey there Jing,

    hope you're doing good today and thanks for reaching us! :slight_smile:

    This isn't something that's supported by Membership 2 Pro by default, you could use another workaround though, in order to avoid any custom coding which would require a developer.
    Instead of having some dropdown for "members" and "supporters", you can create a specific membership level for "supporters", which can be used to BuddyPress-specific protection rules (these are visible after you enable the "BuddyPress Integration" add-on):

    You may also have to enable the "Multiple Memberships" add-on, so users can join more than one membership at the same time.

    Having a flow like the one you described, requires some custom coding which exceeds the scope of our support, so you have to advise a developer about it.
    Reference: https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-1

    Warm regards,

  • Jing
    • Recruit

    HI you getting me wrong , i don't need a any type of membership for buddy press
    i just want user update his role after the registration using buddy press profile page or membership2
    if membership2 not allow to update a user role, so i don't want to use it
    so if there any another way to do this like using in buddy press page where i add a multiple xtra profile filed


  • Dimitris
    • Support Star

    Hello Jing

    Neither BuddyPress nor Membership 2 Pro have the ability to let members select their user roles. This should be done programmatically, by getting some buddypress profile field value and act accordingly. The following snippet seems that does that trick in my end:

    add_action('xprofile_updated_profile', 'bp_custom_registration_role',10 , 3);
    add_action('bp_core_activated_user', 'bp_custom_registration_role',10 , 3);
    function bp_custom_registration_role($user_id, $key, $user) {
      $userdata = array();
      $userdata['ID'] = $user_id;
      // The name of the BP profile field is "Role"
      $userdata['role'] = xprofile_get_field_data('Role', $user_id);
      // "User1", "User2" and "User3" are the three different options for "Role" field
      if ($userdata['role'] == 'User1')
        $userdata['role'] = 'subscriber';
      if ($userdata['role'] == 'User2')
        $userdata['role'] = 'contributor';
      if ($userdata['role'] == 'User3')
        $userdata['role'] = 'editor';

    You can use it as a MU plugin file, for example in /wp-content/mu-plugins/bp-change-user-role.php (just create the /mu-plugins/ folder, if it doesn't exist already).

    Hope that was some help!
    Warm regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.