I’m trying to specify what buttons appear on a page based on two factors. The first is whether the user is logged in and the second is whether, in the user database, the field ‘type’ matches either of the words ‘temp’ or ‘client’ or is empty. The code I have at the moment to differentiate between logged in or not logged in is:
$w.onReady( () => {
if (wixUsers.currentUser.loggedIn) {
$w(“#login1”).label = “Logout”;
$w(“#account1”).show();
$w(“#account2”).show();
}
else {
$w(“#login1”).label = “Login”;
$w(“#account1”).hide();
$w(“#account2”).hide();
}
} );
This works.
However, the variations I would like are as follows:
User:logged in && Field ‘type’ is empty
$w(“#login1”).label = “Logout”;
$w(“#account1”).hide();
$w(“#account2”).hide();
User:logged in && Field ‘type’ = ‘Client’
$w(“#login1”).label = “Logout”;
$w(“#account1”).show();
$w(“#account2”).hide();
User:logged in && Field ‘type’ = ‘Temp’
$w(“#login1”).label = “Logout”;
$w(“#account1”).hide();
$w(“#account2”).show();
User:logged out regardless of ‘type’
$w(“#login1”).label = “Login”;
$w(“#account1”).hide();
$w(“#account2”).hide();
I am unsure of:
a. how to code the if statement to reference a field in the database (currently called Users)
b. how to combine two if statements
Any help would be appreciated!