I have a simple site menu EXCEPT that I would like to either hide/show a menu item OR alternately enable it and set the path to a specific page depending on the Role of the member.
In CORVID I can take action on currentUser.role
import wixUsers from 'wix-users';
$w.onReady(function () {
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn) {
if (currentUser.role === 'Member_Role') {
//show or hide elements here:
// $w("#horizontalMenu1"').MenuItem(6).show(); <=== yeah not.
// assumption here was I could create pages and show/hide
// the menu item linked based on the role
// Another thing that could work is enable/disable a menuitem
// and change the url/page link based on the role
}
}
But apparently "Horizontal Menus" have no MenuItems which have no visible properties (doh!)
So I suppose I am thinking about this the wrong way. I can find "MEGA MENU" examples but haven't found "SIMPLE MENU" that I can manipulate the properties of example.
So using WIX and Corvid what is the smart way to create a site menu.
Can someone point me in the right direction?
2. Answer to 1 may answer question 2 but, am I better off redirecting the link to the correct page than hiding showing 1 menu-item of several. I have about a dozen roles in this case and more will come along.
Thanks in advance
Robert
Depending on how much work you want to do, you can build your own simple menu that just contains the links to the pages.
Then on the pages themselves, you can have your code check the current user and their member role that you have given them.
https://www.wix.com/corvid/reference/wix-users.html
You can simply have the page setup with all the parts for that member role collapsed on load, so that it will only appear on the page if that member has the correct role.
=========================================================
Otherwise, you can look at doing this in your own menu yourself and only have a menu link appear if a member is logged in with that type of role.
Then you can simply have that unhidden menu button linked directly to your page for that type of member role.
========================================================
If you choose to go the second option or similar, then please make sure that you setup your page permissions too so that only members with a specific role can access that page.
There is a basic example here for a members area from Wix that you can use as a starting point for a page etc.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
You won't need the second page, however it is a good example of how to do it for members only which you could change to suit your needs of member role instead.