The way that I filled out the profile information was to create a register form with email and password, but also containing the additional fields required in my Members collection. Clicking on the Register button lets Wix handle the initial registration, particularly the password encryption, but then additional code populates the Members collection if the registration was successful. On my site the member is automatically approved as part of the workflow. I could have added logic to determine if the Member had been approved but didn’t feel it necessary.
The following code shows how to do this:
import wixUsers from ‘wix-users’;
import window from ‘wix-window’;
import wixData from ‘wix-data’;
$w.onReady( function () {
/********************
- client-side code *
********************/
$w(‘#button1’).onClick( () => {
wixUsers.register($w(‘#email’).value, $w(‘#password’).value, {
“contactInfo”: {
“firstName”: $w(‘#firstName’).value,
“lastName”: $w(‘#lastName’).value,
“emails”: [$w(‘#email’).value]
}
}).then( (result) => {
var newMember = {
title: $w(‘#title’).value,
firstName: $w(‘#firstName’).value,
lastName: $w(‘#lastName’).value,
email: $w(‘#email’).value,
phone: $w(‘#phone’).value,
about: $w(‘#about’).value,
dateJoined: new Date()
};
wixData.insert(“Members”, newMember). catch ( (err) => {
console.log(“error inserting into Members collection” + err);
} );
}). **catch** ( ( err) => {
console.log("error when registering new member " + err);
});
});
})
I hope this helps someone!