Register() address fields not working

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.


and here is my code

// 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.

hi if you find the problem please let me know lol im having problems too

hi buddy Ive partially got it working minus adding the addresses with this code…

the only thing id like with this code would be to check for duplicate emails in the site Db

import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';


$w.onReady(function () {
 //TODO: write your page related code here...

});

export function register_click(event) {
 let emails = [];
 let phones = [];

    emails.push($w('#email').value);
    phones.push($w('#contactNumber').value);

 if ($w('#email').value.length === 0) {
        $w('#emailError').expand()
    } else {
        $w('#emailError').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('#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('#emailError').text = err
        });
    }

}

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.

Syntax

type Address = {
  street: string
  city: string
  country: string
  postalCode: string
}

You can also see this example here for custom validations.

As for duplicate emails, that has been asked about before and look here.

Also, check out Nayeli (Code Queen) example here.
https://codequeen.wixsite.com/membership-dashboard
https://codequeen.wixsite.com/membership-dashboard/the-code
https://codequeen.wixsite.com/membership-dashboard/the-backend-code

The above example is searching for duplicate usernames, however you can use the code to see how to apply it for email duplicates.

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

Yes, will have a look later on once get some free time.

In the meanwhile, have a look at this exmple from Nayeli that I forgot about when posting earlier.

https://www.totallycodable.com/wix/corvid/corvid-registration-code-check-existing-user-and-input-validation

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();
                });
            }

}

This request was hijacked, does anyone have the answer for the address not being able to insert into the contact?

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 :wink:

If you want to add a new post with a link to refer back to this one so that the issues aren’t mixed up again.

Just mention something in the new post so that others know and they don’t moan that you are duplicating your post.

@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…