Hi thanks for your response Idan,
The page(s) in question are members only dynamic pages, linked to a collection that has site member author permission to read
I am using a custom built Register lightbox and Login lightbox and my code uses wixUsers.login and wixUsers.register (rather than the wixUsers.promptLogin function).
I have tried this in the front end code:
$w.onReady(() => {
if (wixUsers.currentUser.role === “Visitor”) {
wixWindow.openLightbox(“Login”)
})
IF the dynamic collection read permissions AND the page permissions are both set to ‘anyone’, this code works fine.
IF the dynamic collection read permission is ‘anyone’ BUT the page permission is ‘members only’ it reroutes to the WIX login lightbox/page (before my onReady code is able to launch my custom login lightbox)
IF the dynamic collection read permissions AND the page permissions are both set to ‘members only’, it goes to 403 page (again, before my onReady code is able to launch my custom login lightbox).
Definitely need to use a router, correct?? I have been trying this code in the router.js (with the necessary imports) but have got nothing to work yet:
export function Client_router(request) {
if (wixRouter.wixRouterUser.role === “Visitor”)
return redirect(“https://www.google.com”)
}
also tried this:
export function Client_router(request) {
let user = request.user
if (user.role === “Visitor”)
return redirect(“https://www.google.com”)
}
Many thanks for any help!