I have set up a page for new users to register which works fine. However after they register i want to redirect them to another page. I am currently trying to do this with .then function however it is not working for me. Any ideas ?
import wixUsers from ‘wix-users’;
import wixLocation from “wix-location”;
$w.onReady( function () {
$w(‘#SignupRegisterButton’).onClick(() => {
wixUsers.register($w(‘#SignupEmailInput’).value, $w(‘#SignupPasswordInput’).value, {
“contactInfo”: {
“firstName”: $w(‘#SignupFirstNameInput’).value,
“lastName”: $w(‘#SignupLastNameInput’).value,
“FirstName”: $w(‘#SignupFirstNameInput’).value,
“LastName”: $w(‘#SignupLastNameInput’).value,
“username”: $w(‘#SignupUsernameInput’).value,
“dob”: $w(‘#SignupDOBDatePicker’).value,
“password”: $w(‘#SignupPasswordInput’).value,
“country”: $w(‘#SignupCountryDropdown’).value
.then( function redirectPage() {
wixLocation.to('https://google.com');
})}
})
});
})
Hello Mike,
You almost had it, but it was on the wrong line,
Here is how it should look:
$w(‘#SignupRegisterButton’).onClick(() => {
wixUsers.register($w(‘#SignupEmailInput’).value, $w(‘#SignupPasswordInput’).value, {
“contactInfo”: {
“firstName”: $w(‘#SignupFirstNameInput’).value,
“lastName”: $w(‘#SignupLastNameInput’).value,
“FirstName”: $w(‘#SignupFirstNameInput’).value,
“LastName”: $w(‘#SignupLastNameInput’).value,
“username”: $w(‘#SignupUsernameInput’).value,
“dob”: $w(‘#SignupDOBDatePicker’).value,
“password”: $w(‘#SignupPasswordInput’).value,
“country”: $w(‘#SignupCountryDropdown’).value
}
}).then(() => {
//Everything went good, user was registered, now going to redirect
console.log(‘user registered successfully’);
wixLocation.to(‘https://google.com’);
}).catch((err) => {
//If there is an error it will not redirect, it will console.log the error
console.log(${err}: Error
)
})
});
Hope this helps,
Majd
Thanks very much, works perfect
i have simillar issues i am having results like: The element selector function (usually $w) cannot be used before the page is ready
thats the code for my signup Form… i need reply asap please i need help
please help
$w(‘#SignupRegisterButton’).onClick(() => {
$w(‘#SignupEmailInput’).value, $w(‘#SignupPasswordInput’).value, {
“contactInfo”: {
“firstName”: $w(‘#SignupFirstNameInput’).value,
“lastName”: $w(‘#SignupLastNameInput’).value,
“FirstName”: $w(‘#SignupFirstNameInput’).value,
“LastName”: $w(‘#SignupLastNameInput’).value,
“accountName”: $w(‘#SignupAccountNameInput’).value,
“signupEmail”: $w(‘#SignupEmailInput’).value,
“password”: $w(‘#SignupPasswordInput’).value,
“confirmPassword”: $w(‘#SignupconfirmPasswordInput’).value,
“phoneNumber”: $w(‘#SignupPhoneNumberInput’).value,
“AccountName”: $w(‘#SignupAccountNameInput’).value,
“accountNumber”: $w(‘#SignupAccountNumberInput’).value,
“packages”: $w(‘#SignupPackagesDropdown’).value
}
.then(() => {
//Everything went good, user was registered, now going to redirect
console.log(‘user registered successfully’);
wixLocation.to(‘/Merge’);
}). catch ((err) => {
//If there is an error it will not redirect, it will console.log the error
console.log(${err}: Error
)
})
});
Please make a separate ticket for this issue.
Can you say Where are you storing those data? As Im new to wix. I won’t understand for login with anymail it log me in so how auth will work and how to do sign up for the user.