The user presses on a button, then he/she are redirected to the login/signup page. Is there a way to redirect them to the original intent before the login/signup?
Any way i can keep the page they were suppose to go to and after the login or sign up - redirect them there?
If you code the login/signup process it will return a promise and inside that promise you can use wixLocation.to(“url”) and redirect them. There are plenty of posts here in the forum if you search for it.
It doesn’t run the promise. Is it possible it doesn’t run promises on lightboxes?
Any workaround for this?
export function Button_click(event) {
wixWindow.lightbox.close();
let options = {“mode”: “signup”, “lang”: “en”};
wixUsers.promptLogin(options)
.then( (user) => {
wixLocation.to(“/wantedPage”);
console.log(“redirect”);
} )
. catch ( (err) => {
let errorMsg = err; // “The user closed the login dialog”
} );
}
This code runs from a lightbox… and I must close the lightbox after users presses on registration.
But the promise of the registration which is goto wantedPage never runs… anything i can do? or workaround?
By the way, I tried putting my code in the onReady of the site, but when the lightbox closes it doesn’t call the onReady of the site/page. Perhaps there is any event called when the lightbox closes? so i can write my code there? since the registration pomise is not called on the lightbox
When you open the lightbox you have to make the code that you want to run in the promise in that function.
wixWindow.openLightbox("LightboxName")
.then( (data) => {
// Receives the data from the closed lightbox and here should the code be that you want to run the lightbox closes
} );
Hi, Thank you for your help, I tried it but it didn’t work.
I will explain what i’m trying to do, maybe there is a better way of implementing it.
I have a button that when you press on it - if you are logged in - you are directed to a site member page, but if you are not logged in, I open a light box that explains the user that he must register or log in first, with the option to register (button) and the option to log in (link).
Once he presses on one of them (either) he is directed to the login/signup screen and afterwards he is not directed to the original page…
i tried putting the code inside the signup/login promise (it doesn’t work - probably because that code is in the lightbox)
I tried putting that code inside the promise of the lightbox closure (it still doesn’t work - probably because the signup/login is called at that stage)
Your help is highly appreciated
@anatarad Simple answer, make your own custom login and register feature in your lightbox. if they click LOGIN display login and password input boxes and by code use the .login method in the wixUsers library. If they click register add the input fields you need and use the .register method in the wixUsers library. Problem solved.
@andreas-kviby but then I need to implement everything wix implements in the signup/login. I need to enable facebook, google, email ect… That’s why I wanted to use Wix’s signup/login
hello,
did you manage solve this issue?
I have a similar problem. For example: when a user clicks on a link that is generated by the forum email notification, it directs them to the custome lightbox log in page. (forums are for registered users only) however, after they log in, since the lightbox’s code says
" .then( (user) => {
wixLocation.to (“/homePage”);
}
it takes them to the home page vs the forum to continue the discussion.
any help to redirect them to the right place, where they intended to go?
thanks
-AA