Is it possible to set the lightbox exclusively for members who have a certain role. If so, an exact code would be very nice.
Yes. First go to the lightbox settings and turn off the automatic popping up.
On the page from which you want to trigger the lightbox, use code like:
import wixWindow from 'wix-window';
import wixUsers from 'wix-users';
let rolesForLightbox = ['Seller', 'Writer',/*any role*/];
let user = wixUsers.currentUser;
$w.onReady(() => {
let showLightbox = false;
user.getRoles()
.then(r => {
rolesForLightbox.forEach(e =>
if(r.some(i => e === i.name)){
showLightbox = true;
}
})
if(showLightbox){
wixWindow.openLightbox('LightboxName');
}
})
})
Am I right in thinking this isn’t written with security in mind? An adversary can just edit the frontend code to bypass the permissions check, correct? That threat may well be beyond the scope of what OP is concerned about but you should mention it nonetheless.
I can think of ways to make it more secure but there’s a good chance OP doesn’t really need to overcomplicate things.