I’ve been trying to make a page that displays different elements based on different users’ member roles. I have several collapsed strips with different info based on the roles I’ve created. I have the roles typed exactly as I have them in the Dashboard.
This is the code I have so far and I’ve been testing on the live site but it has not worked yet.
Have I set something up incorrectly?
import wixUsers from 'wix-users';
$w.onReady(function () {
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn) {
if (currentUser.role === 'Admin') {
$w('#stripNoOrders').collapse();
$w('#stripNC').expand();
$w('#stripPOE').expand();
}
if (currentUser.role === 'PrinciplesExcellence') {
$w('#stripNoOrders').collapse();
$w('#stripPOE').expand();
}
if (currentUser.role === 'ncGrade1') {
$w('#stripNoOrders').collapse();
$w('#stripNC').expand();
}
if (currentUser.role === 'ncGrade2') {
$w('#stripNoOrders').collapse();
$w('#stripNC').expand();
}
if (currentUser.role === 'ncGrade3') {
$w('#stripNoOrders').collapse();
$w('#stripNC').expand();
}
if (currentUser.role === 'ncGrade4') {
$w('#stripNoOrders').collapse();
$w('#stripNC').expand();
}
if (currentUser.role === 'ncGrade5') {
$w('#stripNoOrders').collapse();
$w('#stripNC').expand();
}
if (currentUser.role === 'ncKindergarten') {
$w('#stripNoOrders').collapse();
$w('#stripNC').expand();
}
}
})
I was able to figure it out by doing some more digging in the forum! This is the final code that works flawlessly. I can probably simplify it further but for now this works great.