Link to Page Depending on Member Permission

Hello,

I have encountered a similar issue before and you can adapt the scenario below:

You need to do the following to achieve the effect you are looking for:

  1. Create roles as instructed here: Creating Member Roles ;
  2. Add members to their respective roles as instructed here: Managing Your Member Roles
  3. Create a backend function to get the role of currently logged-in user:
import wixUsers from 'wix-users-backend';
export function getUserRoles() {
 let user = wixUsers.currentUser;
 return user.getRoles()
        .then((roles) => {
 if (roles.length > 0) {
 return roles[0].name; // "Role Name"
            } else {
                console.log("Member has no roles");
            }
        })
        .catch((error) => {
            console.log("Backend Error: ", error);
        });
}
  1. Import your backend function to get currently logged-in user role in frontend and use it in your front end code:
import { getUserRoles } from 'backend/userRoles'; //Assuming your function is  getUserRoles and backend module is userRoles.jsw
$w.onReady(async function () {
 let newRole = await getUserRoles();
 //Add your code to use the role as you wish

});
  1. Add code to redirect your site visitor to the relevant page using wixLocation API.

This is just an approach I used and you should change it to suit your case.

Good luck!