How to create a registration page and assign role using a dropdown menu?

This could be interessting for you…

And here you will find the one or the other useful little tutorial for your purposes…
https://russian-dima.wixsite.com/meinewebsite

https://www.wix.com/velo/forum/coding-with-velo/assign-role-member

actually I am a beginner so I’m confused how to place these codes and use them and secondly I want to take input from a drop down list for role id

@tanishqsakhuja1999

May i ask you to show your setup first?
How is structured your Log-In-page/Registration-page?
Do you use a custom registration/log-in-page?
Do you use the standard log-in/registration-page?

You do not give enough informations, to work with.
Anybody knows anything about your project. To get more answers, you first should be able to describe your situation much better.

Which elements are used? On which pages?
DATABASES existing? (PrivateMembersData or own one) ?
Did you already installed the wix-members-area in your project?
Do you want to use your own Registration/Log-In-System?
…and so on…

The more INPUT you give —> the more OUTPUT you get! :wink:

@russian-dima I have used custom registration using code snippet available on wix training academy but that code is only useful when you have to make a registration page using email and password. I want an additional drop down menu which has options : employee and customer and then assign these roles to members of my website.
This is what all I have done till now

@tanishqsakhuja1999
Ok, you found an working CODE to create a registration-page.
Where to find this code?
Why you do not show your current setup/current working code ?

Ok, you are trying to generate a two-way-registration (empleyee & customers) .

Everything you have to know, you will find here…
https://www.wix.com/velo/forum/coding-with-velo/assign-role-member

@russian-dima This is the code I am using for registration page. I want to a setup so that when a member chooses a role from the drop down menu I have created in my sign up page and presses the submit button, then automatically that role gets assigned to him/her.
Please can you help me edit this code to meet the requirements

import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function (){
$w ( ‘#register’ ). onClick ( function (){
let email = $w ( ‘#email’ ). value ;
let password = $w ( ‘#password’ ). value ;
wixUsers . register ( email , password )
. then (()=>{
wixLocation . to ( ‘/dashboard1’ );
})
})
})

@russian-dima Also I don’t know where to place the role.jsw file

@tanishqsakhuja1999

Normaly you have already all informations, to achieve your aim.
First try to solve it by yourself. Read all the given information and try to understand them.

If i would now do it for you, this would be some kind of a service/job and such kind of service it not really welcomed here at the Velo-Forum.

I am allow to help, but not to code your project.
If you need a DEVELOPER reach out to —> https://www.wix.com/velo/hire-a-developer , or send me an E-Mail (to be found in my profile).

Everything related to velo-coding can be found in the VELO-API…
https://www.wix.com/velo/reference/$w/dropdown

@russian-dima the point is I’m not getting all information in order to learn. when I am placing this code below the code I showed you above then its not working.

import { roles } from ‘wix-users-backend’;
2
3 export function assignRole ( roleId , memberId ) {
4 return roles . assignRole ( roleId , memberId , { suppressAuth : true })
5 . then ( () => {
6 console . log (“Role assigned to member”);
7 })
8 . catch (( error ) => {
9 console . log ( error );
10 });
11 }

@tanishqsakhuja1999
I will take a look on it tomorrow.

@russian-dima yeah sure thanks a lot

@tanishqsakhuja1999 As i can see, you already were able to solve your issue. Congrats!

@russian-dima thanks a lot!
Please can you help me with the new issue of dashboards which I have posted recently

@russian-dima This one: