Stop standard login prompt

I have created a custom login page but when I access private pages, the standard login prompt always pops up. I tried to use wixLocation.to to redirect but had no luck. Is there any way to stop the standard login prompt and add a redirect?
I also tried a custom lightbox and linked it in Custom Signup Setting but didn’t work

Thank you for your time

#stop #login #prompt #redirect

Hey
This is probably because you do not handle any custom login event or code right. What I usually do is that in the Site Code Tab I add code to check if the user is logged in or not. If the user is not logged in I redirect them using the wixLocation.to to my custom login page. This way I can make sure all protected pages accessed by non-logged-in users will be redirected to my custom login page.

But if I put the code in the site tab they will be redirected even when they are accessing the homepage and I don’t want that. And even if I use the code

$w.onReady( function () {
if (!wixUsers.currentUser.loggedIn) {
wixLocation.to(‘/login’)
}
})

If I access directly http://mysite.com/account the standard login prompt still pops up and it doesn’t redirect. This is what I want to stop

@danieltanasec Hey
Try this

$w.onReady(function () {
  if (!wixUsers.currentUser.loggedIn && wixLocation.url !== "https://www.domain.com/home") {            
    wixLocation.to('/login')     
  } 
})

Or if you know as I usually do that all protected pages will be under /admin/ or /account/ and so on I use this.

$w.onReady(function () {
 if (!wixUsers.currentUser.loggedIn && wixLocation.url.contains( "/account") { 
   wixLocation.to('/login')
    }
  })

I hope it helps.

@andreas-kviby Hey
Thanks for the fast reply. with the first code in the website section I get the redirect but the login prompt still appears and it redirects after I close it…

@danieltanasec Do you have permissions on your login page maybe by misstake? I have this in many sites and it works

Did it work?

@andreas-kviby Nope… The login permission is set on Everyone. Otherwise I would’t have been able to access it until now

I hoped that if I write the code before onReady() will work but no luck. Anyway I saw that other people tried similar thing in the forum and had no luck also with redirect on private pages

@danieltanasec Hey
Just a thing more so I do not make a misstake, the pages is not Member Pages right that they are trying to access?

@andreas-kviby They are member pages. It’s not the same thing as making a normal page private (Members only) ?:slight_smile: