Hello guys !
When I used the basic/native sign up form from Wix (email + password only), I added a little piece of code which created automatic entries like user ID and email in my “MemberProfile” database.
Now, I’m using a custom registration form on a lightbox with fisrt name, last name, email and password. When a user sign up, a new contact is created in my contact list but I need, like in the past, to auto-create a new entry in my “MemberProfile” database. The point is, my old code, the one for the native Wix sign up form, doesn’t works on my lightbox. Any solution for me ?
If that can help, here is (one of !) the code I tried but doesn’t work :
import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;
import wixData from ‘wix-data’;
$w.onReady( function () {
let user = wixUsers.currentUser;
let userId = user.id;
$w("#registerButton").onClick( (event) => {
let email = $w(“#email”).value;
let password = $w(“#password”).value;
let first = $w(“#firstName”).value;
let last = $w(“#lastName”).value;
wixUsers.register(email, password, {
contactInfo: {
“firstName”: $w(‘#firstName’).value,
“lastName”: $w(‘#lastName’).value,
}
} )
.then( () => {
let toInsert = {
“prenom”: $w(“#firstName”).value,
“nom”: $w(“#lastName”).value,
“email”: $w(“#email”).value,
};
wixData.insert(“MemberProfile”, toInsert)
. catch ( (err) => {
console.log(err);
wixLocation.to(/MemberProfile/Update/${wixUsers.currentUser.id}
);
} );
} );
} );
});