Assigning dynamic role to the user on first signup

Hi Everyone,

During the signup process, I would like the user to specify the role he would like to be a part of. After he selects a role and enters other sign up information and enters sign in. I would like to create a user and assign him a role using rules by hitting management api end point to assign user a new role. But I am not able to figure out that how can I access the “role” data in the rule? I have seen many blogs and conversations on how to assign a default role to a user on his first sign in but I would like to assign him a role, that he selected in the signup form, so how can create an information flow, so as to be able to access the “role” data in the rule.

Regards
Kapil Thukral

Hi @thanosdevelopers,

Welcome to the Community! I apologize for the delayed response.

You can accomplish this with a few tools.

  • First, customize the Classic Universal Login page to add an additional signup field, specifically a select field. This data will then be added to the user metadata. You can actually use this instead of a role. Roles are typically assigned by an admin and are used for access control.

  • If you do want to convert the metadata to a role, you can then use a rule that adds the role conditionally, similar to how it is done in this post, except you will have to look at the user_metadata to see what role to assign.

Hope this helps,
Dan