Hi, we have the following situation:
Our client has a members only area. To access these pages we use the WIX Member App to enable our users to login to the site.
We need the registration form to include two additional fields (firstname, lastname). To do so I followed this guide: Velo Tutorial: Creating a Custom Registration Form with Code | Help Center | Wix.com
So we want EVERYTHING in the registration process to be as it is now (Emails sent for confirmation, user added to the contact list) but with two additional fields (Firstname, Lastname)
This is my code for the new registration page:
import wixUsers from 'wix-users';
function formChanged() {
const passwordValid = $w("#password").valid
const emailValid = $w("#email").valid
const dsgvoValid = $w("#dsgvoCheck").valid
const isFormValid = passwordValid && emailValid && dsgvoValid
if (isFormValid) {
$w('#submit').enable()
console.log('valid') }
else {
$w('#submit').disable() }
}
$w.onReady(function () {
$w('#submit').disable()
$w('#email').onChange(formChanged)
$w('#password').onChange(formChanged)
$w('#dsgvoCheck').onChange(formChanged)
$w('#submit').onClick( () => {
console.log('clicked')
// register as member using form data
wixUsers.register($w('#email').value, $w('#password').value, {
"contactInfo": {
"firstName": $w('#vorname').value,
"lastName": $w('#nachname').value,
"emails": [$w('#email').value], } })
.then( (result) => {
let status = result.status; // "Pending"
let approvalToken = result.approvalToken;
let user = result.user; console.log(result)
console.log('registered') } ); }); });
But nothing happens when I clickl submit. The first console logs fire (‘valid’, ‘clicked’ )but not the ones in the wixUsers.register. I have no idea where I am going wrong.
Can you please add a following catch clause to the register call?
Also, please note, you have an unnecessary comma after: “emails”: [$w(’#email').value],
wixUsers.register(
$w('#email').value,
$w('#password').value,
{
"contactInfo": {
"firstName": $w('#vorname').value,
"lastName": $w('#nachname').value,
"emails": [$w('#email').value]
}
}
).then( (result) => {
let status = result.status; // "Pending"
let approvalToken = result.approvalToken;
let user = result.user;
console.log(result)
console.log('registered')
})
.catch(err => console.log(JSON.stringify(err)));
as first step, u can console.log email, password and ContactInfo and make sure all values are valid (e.g. no null values, password is at least 5 chars, email is of valid format).
if problem still happens, u can send to my email (tomp@wix.com) your website and page where registration form is, and i will try to debug.