I have set up d ynamic page repeater to display what a user has access to based on their role, badge, or anything I can tag the member with to allow them access to repeater. Non-members can view the page of items/pages of non-role or badge not marked.
Picture below is a member view signed in with a Bronx Badge and Labeled Bronx. They should only see the bronx labeled repeater on the dynamic page.
I have been waiting for years to find a code that doesn’t require users to login or sign up to see the page but in order for them to access other pages they must sign up to so. Also depending on their (Role / Membership / Badge) they will have assigned to them from Admin. They are customers and are not part of the a dministration. I am not an expert in wix code or corvid but I found a page that says it " [SOLVED] Filter repeater based on Member Role" www.wix.com/corvid/forum/community-discussion/solved-filter-repeater-based-on-member-role
I tried to use the code, But found I lack the experience to understand exactly how to use this code for my website. Below.
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
let user = wixUsers.currentUser;
$w.onReady(function () {
$w("#projectsDataset").onReady(() => {
console.log("The dataset is ready");
//collapse repeater until filter is complete
if (user.loggedIn) {
user.getRoles()
.then(r => {
if (r.length > 0) {
let roleValues = [
// role = role name, value = value in database field
{role: "roleFilter", value: "Bronx" },
// Change according to your Role names, and database field values
{ role: "roleFilter", value: "Brooklyn" },
{ role: "roleFilter", value: "Manhattan" },
{ role: "roleFilter", value: "admin" },
] //etc, for as many roles as you have
console.log("roles");
$w("#projectsDataset").setFilter(wixData.filter()
.then(() => {
console.log("Dataset is filtered");
})
)}
})
}
})
})
Please help.