I created a custom registration form and it doesn’t work. What is wrong with it? Here is the code:
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;
import wixWindow from ‘wix-window’ ;
$w.onReady( function () {
$w( ‘#registerButton’ ).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,
let toInsert = {
“_id” : wixUsers.currentUser.id,
“firstName” : $w( ‘#firstName’ ).value,
“lastName” : $w( ‘#lastName’ ).value
};
wixData.insert( “Members” , toInsert)
.then( (results) => {
let item = results; //see item below
} )
. catch ( (err) => {
let errorMsg = err;
} );
/* item is:
*
- {
- “_id”: “rifk4nrk-dj4o-djhe-oidk-fnoqw4oiglk4i”,
- “_owner”: “ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb”,
- “_createdDate”: “2017-05-24T12:33:18.938Z”,
- “_updatedDate”: “2017-05-24T12:33:18.938Z”,
- “title”: “Mr.”,
- “first_name”: “John”,
- “last_name”: “Doe”
- }
*/
export function registerButton_click(event) {
.then(()=>{
wixLocation.to( ‘/home’ );
}
. **catch** ( (err) => {
let errorMsg = err; $w( ‘#errorMsg’ ).show();
}
});
});
});
export function login_click(event) {
wixWindow.lightbox.close( ‘Register’ );
wixWindow.openLightbox( ‘Login’ );
}
export function close_click(event) {
wixWindow.lightbox.close( ‘Register’ );
}
#custom #registration #form #forms #customregistration #customregistrationform