Custom Registration

Hi
I used the code below for my custom registration form and notice that the “Phone” field wont write back to the CRM. Can someone please assist me with this?

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
// …
$w.onReady( function (){

$w('#register').onClick( **function**  (){ 

let email = $w(‘#email’).value;
let password = $w(‘#password’).value;
let firstName = $w(‘#firstName’).value;
let lastName = $w(‘#lastName’).value;
let phone = $w(‘phone’).value;

wixUsers.register(email, password, {
contactInfo: {
“firstName”: firstName,
“lastName”: lastName,
“phone”: phone

} 

} )
.then(()=>{

        wixLocation.to('/my-account');  

} )
})
})

I have managed to fix this.

Hi @paven6996 ,
Can you share the solution? So in case other users run into the same problem they can use your answer.

This is the code that worked

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
// …
$w.onReady(function(){

$w('#register').onClick(function (){ 

let email = $w(‘#email’).value;
let password = $w(‘#password’).value;
let firstName = $w(‘#firstName’).value;
let lastName = $w(‘#lastName’).value;
let phone = $w(‘#phone’).value;

wixUsers.register(email, password, {
contactInfo: {
“firstName”: firstName,
“lastName”: lastName,
“phones”: [phone]

} 

} )
.then(()=>{

        wixLocation.to('/my-account');  

} )
})
})

1 Like

@Or,

This has been addressed before.
The proper variable is an array called “phones”
The Wix documentation was wrong at Wix Code launch, and has not been updated yet.

https://www.wix.com/corvid/reference/wix-users.html#register