I am trying to create a custom members registration light box, however it seems like all attempts results in "bad requests", as per the console log. I cant tell what is causing the bad request, I tried different emails (which are not on the dashboard site members page), still does not work. I am at a lost. Can someone please help me?
Do I have to somehow link the wixUsers.registration to a database or the dashboard?
Here is the code I used:
import wixUsers from 'wix-users'; import wixLocation from 'wix-location'; import wixWindow from 'wix-window'; import wixData from 'wix-data'; $w.onReady(function () { $w("#registrationbutton").onClick((event) => { $w("#emailerrormsg").hide(); if (!($w('#firstname').valid && $w('#lastname').valid && $w('#email').valid && $w('#phoneno').valid && $w('#password1').valid && $w('#password1').value === $w('#password2').value)) { let validationMessage = ''; if (!$w('#firstname').valid || !$w('#lastname').valid) { validationMessage += 'Please enter your name\n'; console.log("Name error"); } if (!$w('#email').valid) { validationMessage += 'Please enter a valid Email\n'; console.log("email error"); } if (!$w('#password1').value) { validationMessage += 'Please enter a password\n'; console.log("No password entered") } if (!($w('#password1').value === $w('#password2').value)) { validationMessage += 'Password and Confirm Password fields do not match\n'; console.log("password does not match"); } $w('#validationmsg').text = validationMessage; $w('#validationmsg').expand(); console.log("Error, Cannot save"); } else { $w('#validationmsg').collapse(); $w("#emailerrormsg").hide(); wixUsers.register($w("#email").value, $w("#password1").value, { contactInfo: { "firstName": $w("#firstname").value, "lastName": $w("#lastname").value, "phones": $w("#phoneno").value } }) .then(() => { console.log("New member registered"); wixLocation.to("/Thankyou"); }) .catch((err) => { let errorMsg = err; console.log(errorMsg); $w("#emailerrormsg").show(); }) } }); });