Hey, im trying to setup a custom registration lightbox. I have created the lightbox with all the fields and the code that works behind it. It all works except for the addresses (i must use the built in addresses as i display those in the my member page). Here is my light box and code. The response i get is Bad Request and not error details.
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
$w.onReady(function () {
//TODO: write your page related code here...
});
export function Register_click(event) {
let emails = [];
let phones = [];
let addresses = []
let address = [{
"street": $w('#street').value,
"city": $w('#city').value,
"zip": $w('#postalCode').value,
"country": $w('#country').value
}];
emails.push($w('#email').value);
phones.push($w('#contactNumber').value);
if ($w('#email').value.length === 0) {
$w('#emailError').show()
} else {
$w('#emailError').hide()
}
if ($w('#password').value.length === 0) {
$w('#errorPassword').show()
} else {
$w('#errorPassword').hide()
}
if ($w('#password').value.length > 0 && $w('#email').value.length > 0) {
// register as member using form data
wixUsers.register($w('#email').value, $w('#password').value, {
"contactInfo": {
"addresses": address,
"firstName": $w('#firstName').value,
"lastName": $w('#lastName').value,
"emails": emails,
"phones": phones,
"Hear-about-us": $w('#hearFrom').value,
"DOB": $w('#DOB').value,
}
}).then((results) => {
wixLocation.to('/my-account')
console.log('results', results)
}).catch((err) => {
console.log('err', err)
$w('#emailError').text = err
});
}
}
Is there anything I am missing? I have tried splitting the address out etc but that doesn’t work.
this is the request im sending to the API, notice that it reckons its a custom field???
I have searched all of google and this forum for the anwser and no such luck.
If you want to get the address you have to do it all separately in your signup form as stated in the Wix API Reference and as shown above. https://www.wix.com/corvid/reference/wix-users-backend.html#Address Address
An object that contains information about a site member’s address.
hi thanks Gos i tried adding them separately like above but got no joy, the key field in the new contact db address is only showing the country united kingdom and not the full address, also in the my account page the address fields are blank, im new to code, do you have a snippet you could show me please
hi that code queen tut didn’t work for me probably because im using a light box however Ive managed to solve the duplicate email issue with changing a bit of code above to this
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
import wixCrm from 'wix-crm';
$w.onReady(function () {
//TODO: write your page related code here...
});
export function register_click(event) {
let emails = [];
let phones = [];
let street = [];
let city = [];
let zip = [];
emails.push($w('#email').value);
phones.push($w('#contactNumber').value);
if ($w('#email').value.length === 0) {
$w('#emailExists').expand()
} else {
$w('#emailExists').collapse()
}
if ($w('#password').value.length === 0) {
$w('#errorPassword').expand()
} else {
$w('#errorPassword').collapse()
}
if ($w('#password').value.length < 8) {
$w('#errorPassword').expand()
} else {
$w('#errorPassword').collapse()
}
if ($w("#checkbox1").checked === true)
if ($w("#checkbox2").checked === true)
if ($w('#password').value.length > 8 && $w('#email').value.length > 0) {
// register as member using form data
wixUsers.register($w('#email').value, $w('#password').value, {
"contactInfo": {
"street": $w('#street').value,
"city": $w('#city').value,
"zip": $w('#postalCode').value,
"country": $w('#country').value,
"firstName": $w('#firstName').value,
"lastName": $w('#lastName').value,
"emails": emails,
"phones": phones,
"trade": $w('#trade').value,
"dob": $w('#dob').value,
}
}).then((result) => {
let resultStatus = result.status;
wixWindow.lightbox.close();
wixWindow.openLightbox("registerSuccessBox");
}).catch((err) => {
console.log('err', err)
$w('#emailExists').text = err
$w('#emailExists').expand();
});
}
}
I haven’t forgotten, just not had much time to get on here to do things.
I will try to look at it today or tomorrow for you and yes I can see that there are two seperate issues going in here.
Finally, not a good idea to post anything confidential like that image of your results without masking things out.
Might be worth just deleting the pic itself, although I will just say that it seems it is a small world around this Corvid Forum! Plantation Rd was an old street of mine many years ago now
@givemeawhisky has anyone else solved the address fields not saving to the member/contact list, I am trying to get it to save, if some has the code that would be great. All my other fields are saving
Is there a new thread for this question? Perhaps we should file a feature request, because it seems the API is not supporting setting the Address and you will need to replicate the address fields inside Contactinfo…