Custom Registration Form Error (SOLVED!)

Hello,

So I’m building a custom registration form that collects the basic info plus a few more fields. Right now I got it working using this Wix article (when info is submitted, a site member is created and awaits approval, as it should). The issue I’m having is that the data that I collect through the form does not get added to the new Site Member. The only info that is “registered” is the first/last name and email (none of the other fields). I know it’s going to be an error in my code, just don’t know what as I am not very familiar with JS.

Any fields that are not default fields I created as Custom Fields through the Contacts tab on the dashboard.

Thank you in advance for any help!
Luke



import wixUsers from 'wix-users';

$w.onReady(function () {
  $w('#buttonSubmit').onClick( () => {
  let emails = [];
 
 // register as member using form data
     wixUsers.register($w('#email').value, $w('#password').value, {
 "contactInfo": {
 "firstName": $w('#firstName').value,
 "lastName": $w('#lastName').value,
 "company": String($w("#company").value),
 "position": String($w("#position").value),
 "phone": Number($w("#phone").value),
 "resaleID": Number($w('#resaleID').value),
 "website": String($w('#websiteUrl').value),
       }
    });
  });
});

#CustomRegistrationForm #RegistrationForm #Solved

Totally forgot I had this here and it’s been a while since I solved the issue. I’ll paste my final code below for anyone who wants to use it, hope it helps.

I can’t remeber exactly what I had to do to get this working, I just remember it took me a while hahaha! Anyways, what I think was one of the big issues was making sure that the fields I was trying to register already exsisted as fields in contacts (see attached screenshot) and making sure that they were spelled correctly and had correct grammar for coding (so no caps for first word). I also connected all the fields from my registration form to a database to store info. This is a good backup in case there is a glitch and a user isn’t added but now you have all the info they submitted and can create their account manually if you really need to.

One line of code that isn’t in my old code but is there now (and I don’t remeber is this was a vital part) was the:

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

That may have been a pretty important line of code, but don’t remember exactly. It’s there in my final working version.

There was a lot that went into this and since it was a while back I can’t remeber it all exactly but please feel free to ask questions and I’ll take a look and see what I’ve done. Happy to help any way I can!

Thanks,
Luke


import wixUsers from 'wix-users';

$w.onReady(function () {
    $w('#buttonSubmit').onClick( () => {
    let emails = [];
    
    emails.push($w('#email').value);
    
    // register as member using form data
    wixUsers.register($w('#email').value, $w('#password').value, {
      "contactInfo": {
        "firstName": $w('#firstName').value,
        "lastName": $w('#lastName').value,
        "resaleID": Number($w('#resaleID').value),
        "company": String($w("#company").value),
	"position": String($w("#position").value),
        "phone": Number($w("#phone").value),
	"website": String($w('#websiteUrl').value)
        }
    });
  });
});

Although to be honest, if you had followed the tutorial as shown here.
https://support.wix.com/en/article/corvid-tutorial-creating-a-custom-registration-form-with-code

And made sure that you entered the code originally as stated in the tutorial itself.

Now, we get the email address the user entered and store it in the emails array.

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

Then it should have worked for you in the first place and not needed the original question in this forum. :wink:

Yeah, I was following that and I think at the time when I posted this and didn’t have the emails.push I was having that error but then after re-adding that I was still getting errors. Too long ago so I don’t remember exactly but I know that I read that tutorial a million times over and checked every line to make sure I was doing it right. Oh well.