I have two roles setup in member management ( i.e. Role A and Role B)
I have setup two member only hidden page , one for Role A only and other page for Role B only
How can i direct Role A and Role B members to their own page after login?
Moreover, is there any function that hidden page will only show after permitted member login?
If you want to direct users to their pages according to the role - you’ll first need to get the role of the current user . It would look something like that:
wixUsers.currentUser.getRoles()
.then((roles) => {
let currentRole = roles[0];
if(currentRole === "Role A"){
//direct the user to the Role A page.
} else if(currentRole === "Role B") {
//direct the user to the Role B page.
}
About the hidden page question, it is not possible to effect/change the visibility status of a page via code.
What you can do is to set the page to ‘hidden’ and once you recognize that the user holds one of the roles (you can add this to the code above) simply show( ) a button that navigates to the relevant page
The code I shared before is a snippet that requires adjustments to your site.
You obviously need to add all the imports of the API’s that are included in it, such as - wixUsers wixLocation
You can do it like this (by connecting the buttons directly to the pages you want) or you can use a single button and run this code every time it is clicked and according to the result you’d get - send the user to the relevant page.