Hi All. Creating a custom registration form. Wanted to map some custom fields through the same.
Registration process works fine, but the custom fields do not show up.
Weirdly enough, the one custom field that I hard-coded shows up in the contacts, but not the one from the input fields.
Possible bug or just some silly mistake?
Code is below:
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
import wixData from 'wix-data';
let registration;
import { authentication } from 'wix-members';
$w.onReady(function () {
if (wixUsers.currentUser.loggedIn) {
wixLocation.to("/account/member-home"); //Change the URL ending to the page you want to redirect the user if they are already logged in
}
$w("#registrationButton").onClick((event) => {
console.log("Button was clicked"); //You can change the text of this line or delete it
$w('#errorMessage').hide(); //We want to hide all error messages when the person attempts to register again
$w('#emailExists').hide(); //We want to hide all error messages when the person attempts to register again
if ($w("#email").valid && $w("#password").valid && $w("#firstName").valid && $w("#lastName").valid && $w("#switch1").checked) {
registerPerson();
console.log("Trying to register"); //You can change the text of this line or delete it
} else {
$w('#errorMessage').show(); //This is were we prompt the message to show up again ONLY if there is an error
console.log("Missing information"); //You can change the text of this line or delete it
}
});
});
function registerPerson() {
let emails = [];
let labels = [];
let phones = [];
$w.onReady(function () {
$w('#registrationButton').onClick( () => {
const password = $w('#password').value;
const company = $w('#companyName').value;
const email = $w('#email').value;
emails.push(email);
const phone = $w('#phoneNumber').value;
console.log("companyname" + $w('#companyName').value);
console.log("code" + $w('#eligibilityCode').value);
phones.push(phone);
let options = {
contactInfo: {
firstName: $w('#firstName').value,
lastName: $w('#lastName').value,
emails: emails,
companyName: $w('#companyName').value,
whatisthis: "123",
eligibilityCode: $w('#eligibilityCode').value,
phones: phones
},
privacyStatus: 'PUBLIC'
}
authentication.register(email, password, options)
.then((registrationResult) => {
const status = registrationResult.status;
// When the site is configured for automatic approval, status is "ACTIVE" and the member is approved and logged in.
console.log('Member registered and logged in:', registrationResult);
wixLocation.to("account/my-account");
})
.catch((error) => {
console.error(error);
let errorMsg = error;
$w('#emailExists').show();
});
});
});
}
The “whatitis” custom field which is hard code gets shown but the others don’t
companyName: $w('#companyName').value, // this one doesnt
whatisthis: "testvalue", //this one shows up
eligibilityCode: $w('#eligibilityCode').value, //this one doesnt