The code is correct as can be seen in the Wix Users API and the register function itself here.
https://www.wix.com/corvid/reference/wix-users.html#register
How are you approving your site members? For my posted code originally you will have noticed that the client manually approved each new site member.
https://support.wix.com/en/article/approving-a-site-member
I would suggest that you go through masking out all of the additional lines as below and then unmask one at a time and test it to see if it runs or not.
If one fails then double check your custom fields and make sure that they are exactly the same in the code and in your contact list.
-
How They Heard must be How They Heard;
-
How they heard must be How they heard;
So first time test like this…
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#submitButton").onClick(() => {
let email = $w("#email1").value;
let password = $w("#password").value;
let firstName = $w("#firstname").value;
let lastName = $w("#lastname").value;
let phone = $w("#phone").value;
//let position = $w("#position").value;
//let howTheyHeard = $w("#dropdown1").value;
//let organization = $w("#organization").value;
//let address = $w("#address").value;
//let gradeLevel = $w("#gradeLevel").value;
//let comments = $w("#moreinfo").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName": $w('#firstname').value,
"lastName": $w('#lastname').value,
//"phone": $w("#phone").value,
//"position": $w("#position").value,
//"how they heard": $w("#dropdown1").value,
//"organization": $w("#organization").value,
//"address": $w("#address").value,
//"grade level": $w("#gradeLevel").value,
//"comments": $w("#moreinfo").value
}
})
.then((result) => {
let resultStatus = result.status;
wixWindow.lightbox.close();
wixLocation.to("/member/me");
});
});
});
Second time test like this and so on…
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#submitButton").onClick(() => {
let email = $w("#email1").value;
let password = $w("#password").value;
let firstName = $w("#firstname").value;
let lastName = $w("#lastname").value;
let phone = $w("#phone").value;
let position = $w("#position").value;
//let howTheyHeard = $w("#dropdown1").value;
//let organization = $w("#organization").value;
//let address = $w("#address").value;
//let gradeLevel = $w("#gradeLevel").value;
//let comments = $w("#moreinfo").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName": $w('#firstname').value,
"lastName": $w('#lastname').value,
"phone": $w("#phone").value,
"position": $w("#position").value,
//"how they heard": $w("#dropdown1").value,
//"organization": $w("#organization").value,
//"address": $w("#address").value,
//"grade level": $w("#gradeLevel").value,
//"comments": $w("#moreinfo").value
}
})
.then((result) => {
let resultStatus = result.status;
wixWindow.lightbox.close();
wixLocation.to("/member/me");
});
});
});