Hi, we have the following situation:
Our client has a members only area. To access these pages we use the WIX Member App to enable our users to login to the site.
We need the registration form to include two additional fields (firstname, lastname). To do so I followed this guide: https://support.wix.com/en/article/how-to-create-a-custom-registration-form
So we want EVERYTHING in the registration process to be as it is now (Emails sent for confirmation, user added to the contact list) but with two additional fields (Firstname, Lastname)
This is my code for the new registration page:
import wixUsers from 'wix-users';
function formChanged() {
const passwordValid = $w("#password").valid
const emailValid = $w("#email").valid
const dsgvoValid = $w("#dsgvoCheck").valid
const isFormValid = passwordValid && emailValid && dsgvoValid
if (isFormValid) {
$w('#submit').enable()
console.log('valid') }
else {
$w('#submit').disable() }
}
$w.onReady(function () {
$w('#submit').disable()
$w('#email').onChange(formChanged)
$w('#password').onChange(formChanged)
$w('#dsgvoCheck').onChange(formChanged)
$w('#submit').onClick( () => {
console.log('clicked')
// register as member using form data
wixUsers.register($w('#email').value, $w('#password').value, {
"contactInfo": {
"firstName": $w('#vorname').value,
"lastName": $w('#nachname').value,
"emails": [$w('#email').value], } })
.then( (result) => {
let status = result.status; // "Pending"
let approvalToken = result.approvalToken;
let user = result.user; console.log(result)
console.log('registered') } ); }); });
But nothing happens when I clickl submit. The first console logs fire ('valid', 'clicked' )but not the ones in the wixUsers.register. I have no idea where I am going wrong.
Thanks for any help
hello guys, do you have any update on this? I am having the same error as "Internal Server Error 500".
thanks in advance.
Hi skrobek,
as first step, u can console.log email, password and ContactInfo and make sure all values are valid (e.g. no null values, password is at least 5 chars, email is of valid format).
if problem still happens, u can send to my email (tomp@wix.com) your website and page where registration form is, and i will try to debug.
Thanks
Hi Genry,
thanks for the reply. I updated the code as suggested but all I get from the catch is: "Internal Server Error (500)". The error log shows this:
POST https://www.REDACTED-MY-DOMAIN.de/api/wix-sm/v1/auth/register 500 (Server Error)
Any ideas? Thanks ...
HI skrobek.
Can you please add a following catch clause to the register call?
Also, please note, you have an unnecessary comma after: "emails": [$w('#email').value],
wixUsers.register( $w('#email').value, $w('#password').value, { "contactInfo": { "firstName": $w('#vorname').value, "lastName": $w('#nachname').value, "emails": [$w('#email').value] } } ).then( (result) => { let status = result.status; // "Pending" let approvalToken = result.approvalToken; let user = result.user; console.log(result) console.log('registered') }) .catch(err => console.log(JSON.stringify(err)));
Regards,
Genry.