Hay Jonathan,
Wix does not have a feature for different groups of Site Members. Having said that, Wix Code allows you to develop something like that yourself, using our coding features. I am gonna try directing you at how to build something like this, but not knowing your exact use case you may need to adjust it for it.
First of all, to restrict access to a page, you can do so using three different features, depending on the page type.
For a regular page, you can have in the page code, as part of the onReady event handler, a code that checks for a user access to the page and redirects the user to another page in case of no access.
Such a code looks like
import checkAccess from 'public/check-access';
$w.onReady(() => {
return checkAccess();
});
and the check access file
import wixLocation from "wix-location";
import wixData from "wix-data";
import wixUsers from "wix-users";
export default function checkAccess() {
if (!wixUsers.loggedIn) {
// no user is logged in
wixLocation.to('/');
return new Promise(() => {});
}
return wixData.get('user-access', wixUsers.currentUser.id)
.then(res => {
if (res && res.group === 'a group with access') {
// the user has access to the page
return Promise.resolve();
}
// the user does not have access to the page
wixLocation.to('/');
return new Promise(() => {});
});
}
What happens here is that we check if there is a logged in user. If so, we query a user-access collection, a collection at which we assume for each user we have a group membership. Then we check that the user’s group membership is allowed access to our page.
If the user has access, we return a resolved promise.
If the user does not have access, we redirect the user to the homepage and return a promise that will not be resolved.
Note that in the onReady code we return the promise that is returned from checkAccess. onReady returned promise is used to control when the page is displayed. Resolving the promise makes the page visible. Calling wixLocation.to and returning a promise that will not be resolved ensures that the page will not appear before we redirect to another page.
For a dynamic page, you can use the beforeRouter hook. This is a more secure method, that works only for dynamic pages or router pages. Using this method, you again check the user access and redirect the user or allow the processing to proceed using the next function. The code looks something like
import {next, redirect} from 'wix-router';
export function items_beforeRouter(request) {
return yourCheckAccessLogic(request.user.id)
.then((hasAccess) => {
if (hasAccess)
return next();
else
return redirect('/');
});
}