Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Allow users to choose multiple roles on registration WordPress

  • REFUNDED

I'm looking for some code I can place in my functions.php that will allow users to choose one or more (multiple) user roles to assign themselves to. That is, a new user can give themselves 3 or 4 or more roles (except Admin of course) - let admin choose which roles users can choose from (I edit this in the code itself) . Also the ability for users to update/change their roles in their wp profile AND BBPress profile. I'd like this to be usable with the native wp registration form, BBPress profile page and wp user profile page.

I want the roles displayed dynamically from those i create via another plugin.

Answers (3)

2020-08-12

Francisco Javier Carazo Gil answers:

You have a plugin in GitHub that allow it to users who can edit users: https://gist.github.com/nikolov-tmw/7808046

Check it and if you want also to include in the own profile include this hooks:

add_action( "show_user_profile", "mrpu_add_multiple_roles_ui" );
add_action( "personal_options_update", "mrpu_save_multiple_user_roles" );


pjeaje comments:

I need you to do it for the $$


Francisco Javier Carazo Gil comments:

Sorry I do not understand your answer.

Copy the plugin and include the lines I sent you.


pjeaje comments:

As per my question... Can your solution do the following?
1. allow users to choose one or more (multiple) user roles to assign themselves to
2. let admin choose which roles users can choose from (I edit this in the code itself) .
3. the ability for users to update/change their roles in their wp profile AND BBPress profile.
4. usable with the native wp registration form, BBPress profile page and wp user profile page.
5. I want the roles displayed dynamically from those i create via another plugin.

2020-08-12

Sébastien | French WordpressDesigner answers:

https://publishpress.com/knowledge-base/multiple-roles-one-user/


pjeaje comments:

That doesn't do as I'm asking... allow users to choose one or more (multiple) user roles to assign themselves

2020-08-12

Farid answers:

Hi there,

Thanks for explaining your requirements properly.

First of all, I wouldn't recommend you allow your users to choose multiple roles or even a single role upon registration upper than a subscriber role initially. The problem in this approach is that any stranger can register on your site with an Editor role or Author role and spoil your site contents.

While when a user registered and you can look at that user information then you can assign a role/roles to them after inspection that it’s not a bot or a stranger.

You can see all the available roles and their capabilities in detail here: https://wordpress.org/support/article/roles-and-capabilities/#administrator

Now the question is that how you can assign multiple roles, while you can edit any role capabilities or create new roles to suit your users' needs instead of adding multiple roles to a user that doesn’t make sense.

A user can be an Administrator or Editor or Author and so on… Now if you assign Author, the user will have some capabilities and now if you choose Editor, that user will have all the author capabilities automatically along with enchanted capabilities of an Editor role. I hope you understand?

Having that in mind you will actually need to edit current WordPress/bbPress roles or add new ones with different tastes of capabilities and you can do that in a very easy way by using the https://wordpress.org/plugins/user-role-editor/ plugin.

This plugin is highly recommended by WordPress experts to edit or enhance WordPress roles and their capabilities.

The same thing goes for the bbPress. For the information about bbPress roles and their capabilities please refer to this page: https://codex.bbpress.org/getting-started/before-installing/bbpress-user-roles-and-capabilities/

Best Wishes!

Fahid


pjeaje comments:

Thanks, I know all of that but unfortunately it doesn't answer my question.