Wix registration form with a lightbox wont work

Good evening
Today i decided to make a social media website and started off with a registration form in lightbox.
The intention is that everyone who types in their email and password and clicks on registration, they will be send to “start”. But it instead stays on the testing page.
This would be the code:

import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function () {});

export function registerNow_click ( event ) {

let email = $w ( ‘#registerEmail’ ). value ;
let password = $w ( ‘#registerpassword’ ). value ;
wixUsers . register ( email , password )
. then (() => {
wixLocation . to ( ‘/start’ );
});

}

I´m looking forward to replies and would be happy for everything you reply with

Hi there :wave:t2: I have a similar setup on my site. Does the code successfully register users as members and the only problem is the wixLocation?

Hi.

You’ll have to debug your code, put this console.log statement inside the .then

console.log("User registered")

You might also want to add an error catch like this:

wixUsers.register(email,password)
.then(()=>{
    //Whatever you want to happen
})
.catch((error) => {
    console.log(error)
})

This way, you can know if there is an issue with registering the user

Hope this helps & happy coding!

Alex

The only problem is the wixLocation yes

To be honest, I really don´t have any clue whatsoever about coding. i don´t really know where to put the code in that you replied with

A few questions / things to double-check:

  1. Are you testing in Preview or on the live site?

  2. Check that the element IDs are all exactly correct with identical capitalization (i.e. "#register p assword" is not the same as "#register P assword" )

  3. If you are testing repeatedly with the same email you will need to delete the test member each time before a new test

  4. Make sure “start” is the correct page name

  5. Test with different pages instead of “/start” to see if it works for another page

  6. Remove the click handler from the button and try the code below instead, it’s based on what I use to successfully add a new member and redirect them to the desired page.

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';

$w.onReady(function () {
    $w('#registerNow').onClick(function () {

        let email = $w("#registerEmail").value;
        let password = $w("#registerpassword").value;

        wixUsers.register(email, password)
            .then((result) => {
                let resultStatus = result.status;
                console.log(resultStatus);
                wixLocation.to("/start");
            })
            .catch((err) => {
                console.log(err);
            });
    });
});
  1. Check your browser’s console log to see if there are any errors when the code is run, and screenshot and send it over

Good luck!

This last code worked out for me, thank you very much!