# Register() address fields not working

**URL:** <https://forum.wixstudio.com/t/register-address-fields-not-working/18851>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [June 14, 2020, 9:09am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851 "2020-06-14T09:09:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristinwhite](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@tristinwhite](https://forum.wixstudio.com/u/tristinwhite)\
**Post date:** [June 14, 2020, 9:09am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/1 "2020-06-14T09:09:38Z")

</div>

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.

 ![](https://us1.discourse-cdn.com/wix/original/3X/4/2/42a99ba6a4b07394822a0a86941c1113b78a22b3.png)  
and here is my code

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

> **[Custom registration and contact info | Velo by Wix](https://community.wix.com/velo/forum/coding-with-velo/custom-registration-and-contact-info)**
>
> Hello, I am new to coding and have run into something I cant seem to solve. 
> I am trying to create a custom member registration for my website that also collects and inputs some contact info into my CRM on Wix.
> If anyone could point me in the right...

> **[Velo by Wix: Full-Stack Web Dev | Build Professional Web Apps](https://community.wix.com/velo/forum/coding-with-velo/member-s-collection-address%3Fpage%3D1%26dl%3D5ce7fb33227f2d0016962c8b%252F5ce333e054670c00a4d64602%252F2)**
>
> Ask questions, get answers from the community and stay up-to-date with new features.

> **[Velo Tutorial: Creating a Custom Registration Form with Code | Help Center |...](https://support.wix.com/en/article/velo-tutorial-creating-a-custom-registration-form-with-code)**
>
> Visit the Velo by Wix website to onboard and continue learning.When you add membership functionality to your site, you receive a default form for registering si

---

<div class="post-metadata">

**Author:** ![millwards322](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/millwards322/32/13622_2.png) [@millwards322](https://forum.wixstudio.com/u/millwards322)\
**Post date:** [June 14, 2020, 1:38pm UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/2 "2020-06-14T13:38:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![millwards322](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/millwards322/32/13622_2.png) [@millwards322](https://forum.wixstudio.com/u/millwards322)\
**Post date:** [June 14, 2020, 6:47pm UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/3 "2020-06-14T18:47:53Z")

</div>

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

```javascript
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
        });
    }

}

```

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [June 14, 2020, 7:29pm UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/4 "2020-06-14T19:29:56Z")

</div>

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](https://www.wix.com/corvid/reference/wix-users-backend.html#Address)  
**Address**  
An object that contains information about a site member’s address.

**Syntax**

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

```

You can also see this example here for custom validations.

> **[Custom Validations](https://www.wix.com/velo/example/custom-validations)**
>
> This example demonstrates how to validate input elements and how forms can be validated using regular expressions and the custom validations API

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

> **[Prevent contact duplicates in custom registration? | Velo by Wix](https://community.wix.com/velo/forum/coding-with-velo/prevent-contact-duplicates-in-custom-registration)**
>
> Is there any way you can use Wix Code to prevent duplicate contacts (same email) for my custom registration page?

> **[Search for duplicate entires? | Velo by Wix](https://community.wix.com/velo/forum/coding-with-velo/search-for-duplicate-entires)**
>
> Hi There,
> 
> I now have over 100 sign ups on my website. I want to know if there is any easy way to check for duplicate entries.
> 
> Basically, I want to easily identify if someone has registered twice.
> 
> Any filter that checks for duplicate...

Also, check out Nayeli (Code Queen) example here.  
[https://codequeen.wixsite.com/membership-dashboard](https://codequeen.wixsite.com/membership-dashboard)  
[https://codequeen.wixsite.com/membership-dashboard/the-code](https://codequeen.wixsite.com/membership-dashboard/the-code)  
[https://codequeen.wixsite.com/membership-dashboard/the-backend-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.

---

<div class="post-metadata">

**Author:** ![millwards322](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/millwards322/32/13622_2.png) [@millwards322](https://forum.wixstudio.com/u/millwards322)\
**Post date:** [June 14, 2020, 9:59pm UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/5 "2020-06-14T21:59:39Z")

</div>

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

 ![](https://us1.discourse-cdn.com/wix/original/3X/b/1/b14492409532553ebf5feacb8e1ce78a5105528f.png)

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [June 15, 2020, 2:39am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/6 "2020-06-15T02:39:24Z")

</div>

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](https://www.totallycodable.com/wix/corvid/corvid-registration-code-check-existing-user-and-input-validation)

---

<div class="post-metadata">

**Author:** ![millwards322](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/millwards322/32/13622_2.png) [@millwards322](https://forum.wixstudio.com/u/millwards322)\
**Post date:** [June 15, 2020, 10:19am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/7 "2020-06-15T10:19:09Z")

</div>

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

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

}

```

---

<div class="post-metadata">

**Author:** ![tristinwhite](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@tristinwhite](https://forum.wixstudio.com/u/tristinwhite)\
**Post date:** [June 22, 2020, 3:38pm UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/8 "2020-06-22T15:38:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [June 23, 2020, 1:27am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/9 "2020-06-23T01:27:28Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [June 23, 2020, 1:29am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/10 "2020-06-23T01:29:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jacindasurvey](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jacindasurvey](https://forum.wixstudio.com/u/jacindasurvey)\
**Post date:** [August 21, 2020, 7:10am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/11 "2020-08-21T07:10:37Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![ronald28659](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ronald28659/32/22508_2.png) [@ronald28659](https://forum.wixstudio.com/u/ronald28659)\
**Post date:** [September 15, 2020, 10:32am UTC](https://forum.wixstudio.com/t/register-address-fields-not-working/18851/12 "2020-09-15T10:32:41Z")

</div>

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…
