Howdy all,
So I have run into a snag in coding what is essentially a custom registration form.
I am letting the members app take care of basic details (contactinfo, password, and email), however, I am trying to create coding that essentially allows user input to determine the users role upon registration.
I have created the .jsw as seen below:
import {roles} from 'wix-users-backend';
export function assignRole(roleId, email) {
return roles.assignRole(roleId, email, { suppressAuth: true })
.then( () => {
console.log("Role assigned to member");
})
.catch((error) => {
console.log(error);
});
}
However, I can’t figure out the logic for the front end.
This is what the sign up currently looks like:
I am using #roleAssign dropdown, which shows 2 options (parent, coach). Ideally, if the user chooses parent they would be assign one role, and if coach is selected this would be assigned another.
I just can’t wrap by head around that logic.
I tried using this code but no luck:
import wixMembers from 'wix-members';
import wixLocation from 'wix-location';
import {assignRole} from 'backend/role';
//AUTO ROLE ASSIGN
$w.onReady(function () {
$w('#create').onClick(function(){
let profileRole = $w('#roleAssign').value;
if(profileRole = "family"){
let roleID ="6078991c-c487-45fc-922f-309bb8312baf";
assignRole(roleID)
}
}
});
Any help or pointers would be greatly appreciated.
Josh