Redirect to homepage after registration

Hi, I’m trying to create a custom sign up page and I’m using this code:


import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
//import wixWindow from ‘wix-window’;

$w.onReady( function () {
$w(‘#submit’).onClick( () => {

const key = $w(‘#key’).value;

if (key === “ZranZ19”){

// register as member using form data
wixUsers.register($w(‘#email’).value, $w(‘#password’).value, {
“contactInfo”: {
“firstName”: $w(‘#firstName’).value,
“lastName”: $w(‘#lastName’).value,
“email”: $w(‘#email’).value,
“phone”: $w(‘#phone’).value,
“Organizace”: $w(‘#organizace’).value
}

}); 

wixLocation.to(“https://dvfilmstudio.wixsite.com/zr001”);
}
});
});


My problem is that when I add the wixLocation.tol line, the registration doesn’t work. Can anybody guess where the problem may be or how to solve redirecting after submitting the form differently?
Thanks a lot!

Hi!

The register() method uses a promise that needs to be resolved before navigating to another page.
Navigating before finishing the action of registration basically cancels it.

I suggest you to look into the method’s API and go over the examples given there.

Hope it helps.

Doron. :slight_smile: