Hi!
Need some help with the redirect function.
I’ve created a sign up lightbox with custom fields using wix members sign up custom form.
I’ve set most of the fields as required. So far everything works perfectly. When the user hit the sign up button all data from the form is stored in the site members dashboard.
Then I added code (found here on the forum) that redirects the user after pushing the submit button to another page on my site.
This also works fine.
The problem is that after adding the code the required fields on the form is no longer active. The user only has to fill in the email and password fields to be able to sign up.
That means I might not get all the info I want/need from the users.
What I’m I doing wrong. Do I have to add something in the code or is it just in the wrong place?
Here’s the code:
import wixUsers from ‘wix-users’;
import wixLocation from “wix-location”;
$w.onReady( function () {
$w(‘#button34’).onClick(() => {
let email = $w(‘#input3’).value
let password = $w(‘#input4’).value
let firstName = $w(‘#input1’).value
let lastName = $w(‘#input2’).value
let phone = $w(‘#input5’).value
let street = $w(‘#input6’).value
let zip = $w(‘#input7’).value
let city = $w(‘#input8’).value
let country = $w(‘#input9’).value
let choir = $w(‘#dropdown1’).value
let checkbox1 = $w(‘#checkbox1’).value
wixUsers.register(email, password,
{
contactInfo: {
“firstName”: firstName,
“lastName”: lastName,
“phone”: phone
}
} )
.then( (result) => {
let resultStatus =
result.status;
wixLocation.to(‘https://www.google.se’);
} );
});
});
Following on from Shan’s great reply above, also note that Nayeli (Code Queen) has recently released a tutorial and youtube video on this which you might want to check out too.
Wow! Thank you Shan! Can’t tell you enough how grateful I am for your answer!
Just tested it and it works like a sharm. Exactly as I wanted it to be.
Can’t believe you not only explained what was wrong with the code but also wrote a complete functional code for me with my own values. You just saved me hours and hours with headache.
Really appreciate your knowledge and kindness of helping me out on this.
Thanks / Regards Kristoffer
Thank you!
Shan’s reply worked great for me, but I will check out the video you linked to aswell. You can never get to much info. Right
Thanks for helping out!
Regards / Kristoffer
Please can you mark Shan’s reply with best answer as you seem to be happy with it.
It will help others find it easier if they run into the same or similar issue, thanks.