I’m trying to create a member registration page that not only collects email and password, but also first and last name, house number, and street name. I also want to manually approve members myself. I created a form and put it onto a unique page. I selected this form under member signup settings. I’m noticing that the “register” and “.then” are not highlighted in orange like the example code.
The form is showing when I go to the site. I get confirmation that the form has been filled out. But it is not making the person a member or asking me to approve them.
Here is what I’m trying to use for code without success:
import wixUsers from ‘wix-users’;
// …
let email = // the user’s email addresses
let password = // the user’s password
let firstName = // the user’s first name
let lastName = // the user’s last name
let houseNumber = //the user’s houseNumber
let streetName = // the user’s streetName
wixUsers.register(email, password, {
contactInfo: {
“firstName”: firstName,
“lastName”: lastName,
“houseNumber”: houseNumber,
“streetName”: streetName,
“email”: email
}
} )
.then( (result) => {
let status = result.status; // “Pending”
let approvalToken = result.approvalToken;
let user = result.user;
});
Hi @tracylyndoyle !
This code you’re using is intended to act as an example but it’s by no means a finished product.
The first part that needs additional work is this:
let email = // the user's email addresses
let password = // the user's password
let firstName = // the user's first name
let lastName = // the user's last name
let phone = // the user's phone number
let nickname = // the user's nickname
The text coming after ‘//’ is called a comment. It explains what the code does to the person reading it but it does not run.
What you need to do is to assign values to each variable like that:
let email = $w('#email'); // the user's email addresses
// what comes after two slashes is a comment
// do the same for the other fields
Replace ‘email’ in $w(‘#email’) with the id of the email input element.
Note: Here I assume you’re not connecting the form to the database collection; in that case you’d probably use a dataset selector instead of $w(‘#email’).
Now, you need to put this code in an event handler so that it’s executed only after the user has clicked submit button.
The particular event handler you should be using depends on how you setup your form.
Most likely you need to add the onClick event handler to your submit button.
Let me know if you face any problems along the way.
Good luck!
Vytautas
Thank you for the feedback. I obviously am unfamiliar with coding and I am trying to figure it out to get this one form to function the way that I want. Does Wix have coders that complete small jobs like this if I can’t figure it out on my own. I know it is probably really simple! Thanks again! Tracy
No, we do not have dedicated coders for tasks like these.
Instead we encourage everyone using Wix Code to be (or become!) a coder 
Usually you can find an answer in Wix Code Resources . You’ve probably found your code snippet in the API Reference which describes the tools that are available to you (like wixUsers.register method). To get a better understanding of how these tools fit together check out our video tutorials and articles with step-by-step guides.
A quick search helped me locate an article which is more or less what you’re looking for: Velo Tutorial: Creating a Custom Registration Form with Code | Help Center | Wix.com
Try to adjust the example code according to your needs.
If something doesn’t work, you can always ask here in the forum or contact Wix Support .
Good luck!
Vytautas
Thanks again. I’m trying to modify the example code but still not having success. I know that I’m still missing pieces. I created a basic form and I’m trying to get the input info from the form into my contacts. I did create two unique columns in contacts for house number and street name. I then want to manually approve their membership. This is what I have so far…
$w.onReady( function () {
$w(‘#button1’).onClick( () => {
// register as member using form data
wixUsers.register($w(‘#input5’).value, $w(‘#input6’).value, {
“contactInfo”: {
“firstName”: $w(‘#input1’).value,
“lastName”: $w(‘#input2’).value,
“houseNumber”: $w(‘#input3’).value,
“streetAddress”: $w(‘#input4’).value,
“emails”: [$w(‘#input5’).value],
}
});
.then( (result) => {
let status = result.status; // “Pending”
let approvalToken = result.approvalToken;
let user = result.user;
});
});
});
There should not be a semicolon before ‘.then’.
Such errors can be detected using the developer console in Preview Mode, or in the console of your browser’s devtools .
Also, if you use console.log method inside your code, then whatever you log will appear in the console:
console.log(result); // logs the value of the result variable
This is useful for debugging purposes.
Note: The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality.
Vytautas,
Thank you so much for your help. I currently have the registration form successfully collecting the data. My last step is to have something happen once the user clicks submit. Right now, the page doesn’t redirect or give a “pending” message. I’d like to have a pending message come up. I’m trying to find tutorials on how to do this. I’m getting so close to having my site live! This is the last step!
Thank you for all of your help,
Tracy
Glad to hear you’re moving forward, Tracy.
You can make elements hidden initially in the properties panel , and show them when something happens, e.g. the registration is successful:
wixUsers.register(/* your parameters go here */)
.then(result => {
// ...
$w('#pendingMessage').show();
})
.catch(error => {
// I assume the registration might fail if the user is already registered or for some other reason
// therefore, you can display the error message
$w('#errorMessage').text = error;
$w('#errorMessage').show();
});
Or if instead of showing the pendingMessage you want to redirect to some page, use wixLocation.to.
Good luck!
Vytautas