i cant complete my code

i have a custom registration page where it contains a dropdown , this dropdown has two options 1 “student” , option 2 “instructor”
i want to determine what type of user who is logged in so i can hide an element
so i thought of connecting these the dropdown value to labels in the dashboard then i’ll add a code in the home page to hide the member bar nav menu based on whether the user is a student or an instructor here’s my signup code

import wixUsers from 'wix-users';
$w.onReady(function () {
$w('#button2').onClick( () => {
let labels = [];
let dropdownSelIndex = $w("#dropdown1").selectedIndex; //
if($w("#dropdown1").selectedIndex = students){
labels.push("students");
} else { ($w("#dropdown1").selectedIndex = instructors)
labels.push("instructors")
}

and here’s the code to my home page where i want to hide the nav menu based on the user selection

import wixUsers from ‘wix-users’;
$w.onReady(function(){
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn)
if (currentUser.label === ‘instructor’) {
$w(‘#accountNavBar1’).hide();
}
}
);


Note that labels are more for your Contact List and not for setting member roles.
https://support.wix.com/en/article/creating-contact-labels
https://support.wix.com/en/article/adding-labels-to-contacts-in-your-contact-list
https://support.wix.com/en/article/predefined-contact-labels

You would be better suited marking the user as a certain member role and then you can simply use the Wix Users API to get the current users role and then do whatever you want with them.

The only drawback currently with member roles is that they can not be set by code, so I can see why you are trying to implement it with your dropdown instead.

https://support.wix.com/en/article/creating-member-roles-6943237
https://support.wix.com/en/article/managing-your-member-roles
https://support.wix.com/en/article/limiting-pages-on-your-site-to-specific-members-member-roles

https://www.wix.com/corvid/reference/wix-users.User.html#getRoles
https://www.wix.com/corvid/reference/wix-users.html#currentUser

Something like this below, although please note that Wix Users will only work properly in a live and published site, do not test it just through the preview.

import wixUsers from 'wix-users';

$w.onReady(function () {
    //TODO: write your page related code here...
    var roleName;
    let currentUser = wixUsers.currentUser;

    currentUser.getRoles()
  .then( (roles) => {
     var firstRole = roles[0];
     roleName = firstRole.name;      
     if(roleName === "RoleNameHere"){
       $w('#someelement').show();
  } );

This is a simple piece of code for getting the users pricing plans and doing something with it, so you can just change it to suit your getUserRole setup.

import wixUsers from 'wix-users';

$w.onReady(function () {

let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;

user.getPricingPlans()
.then( (pricingPlans) => {
let firstPlan = pricingPlans[0];
let planName = firstPlan.name;

if (planName === "Basic Plan") {
$w("#eventtype").disable();
$w("#specialrequests").disable();
$w("#errormessage1").show();
}
else {
$w("#eventtype").enable();
$w("#specialrequests").enable();
$w("#errormessage1").hide();
}}
)})

This is what I have used on a site for working with labels and as you will notice in the code, that I am using Wix CRM as that is what you need to work with the Contacts List from your Wix Dashboard.

import wixCRM from 'wix-crm';

$w.onReady(function() {
$w("#PublicContactUs").onAfterSave(() => {
let name = $w('#publiccontactName').value;
let email = $w("#publiccontactEmail").value;
let subject = $w("#publiccontactSubject").value;
let message = $w("#publiccontactMessage").value;
let label = ["Contacted Us"];

wixCRM.createContact({
"name": name,
"emails": [email]

})
.then((contactId) => {
// Need to use the triggered email name
return wixCRM.emailContact('publiccontactus', contactId, {
"variables": {
// Need to use the triggered email variable names
"name": name,
"email": email,
"subject": subject,
"message": message
}
});
})
.catch((err) => {
// handle the error if the email wasn't sent
console.log(`Error: ${err}`);
});
});
});

$w("#NewSubscriber").onAfterSave(() => {
let name = $w("#newsubscriberName").value;
let email = $w("#newsubscriberEmail").value;
let privacyPolicy = $w("#newsubscriberPrivacy").value;
let label = ["Subscribed"];

wixCRM.createContact({
"name": name,
"emails": [email]

})
.then((contactId) => {
// Need to use the triggered email name
return wixCRM.emailContact('newsubscriber', contactId, {
"variables": {
// Need to use the triggered email variable names
"name": name,
"email": email,
}
});
})
.catch((err) => {
// handle the error if the email wasn't sent
console.log(`Error: ${err}`);
});
});

Plus, if you do a simple search on this forum, you will find previous posts that can help you too.
https://www.wix.com/corvid/forum/community-discussion/user-roles
https://www.wix.com/corvid/forum/community-discussion/set-member-role-using-wix-code
https://www.wix.com/corvid/forum/community-discussion/menu-items-based-on-user-role
https://www.wix.com/corvid/forum/community-discussion/getroles-function-is-not-working/p-1/dl-5e148145dd7d620017498340

so i cant create a role using wix code from a form , only manually ?

or if i have a pre-defined role in my dashboard can i use wix code to connect a dropdown and if one of the two values of the drop down match then this user is assigned to this role ??