Add one field on Login page to import to CMR & Contact list

I have this code, that works fine. It validates the password twice so they are correct. But I’m trying to add a field that will import to CMR & Contacts list as people become members. But I don’t have any idea how…

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;

$w.onReady( function (){
$w(‘#registerNow’).onClick( function (){
let email = $w(‘#mail1’).value;
let password = $w(‘#losen1’).value;
let password2 = $w(‘#losen2’).value;

if (password === password2) {

//if password matches we console.log success message and register the user

console.log(“Dem matchar!”);

wixUsers.register(email,password)
.then(()=>{
wixLocation.to(‘/ny-registerade’);
})

}
//if password does not match console.log error message
else {
console.log(“Dem matchar inte!”);

    } 
}) 
})

Hej där!
You can use the contactInfo I believe that is described here:

let firstName = // get first name
let lastName = // get last name
let email = // get email address
let phone = // get phone number

let contactInfo = {
  "firstName": firstName,
  "lastName": lastName,
  "emails": [email],
  "phones": [phone],
  "customField1": "customValue1",
  "customField2": "customValue2"
};

And by using custom fields I believe that you can register and store information on your contacts like below.

wixUsers.register(email, password, {
    contactInfo: {
        "firstName": firstName,
        "lastName": lastName,
        "phone": phone,
        "nickname": nickname,
        "customField1": "customValue1",
    }
  } )
  .then( (result) => {
    let resultStatus = result.status;
  } );

I hope it will help you. Lycka till.

Oh okey, i will check this out and give it a try! Tack så hemskt mycket :slight_smile: