Please help! I’m the site owner, and I’m using the code below to show elements only to the Admin (me). The console reports that I’m logged in as a member, not as the admin. What could be the problem? Thank you in advance!
import wixUsers from ‘wix-users’;
$w.onReady(function () {
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn && currentUser.role === ‘Admin’){
//Show components:
$w(‘#input1’).show();
$w(‘#uploadButton1’).show();
$w(‘#button1’).show();
}
console.log(currentUser.role);
console.log(currentUser.loggedIn);
});
Still no resolution. Something is definitely buggy about the Wix users API. The Wix documentation says that there are three types of users: visitor, member, and admin. A visitor is a user who is not logged into the site, and admin is the site owner. But the admin obviously must be logged into the site as well; otherwise how would the API distinguish between a visitor and the admin?
Also, the admin apparently cannot also be a site “member,” and contributors designated as “admin” are not admins for purposes of the users object.
Finally, why should I be required to add a “members” login app to achieve this functionality for me, the admin, when the code works without it for visitors (who, by definition, are not logged in)?
I suppose that’s why it’s still in BETA, but frustrating nonetheless.