I am trying to create a custom signup in a lightbox. This is the code I have used however it does not seem to submit the new member or navigate to the next page. Is anyone able to tell me where I have gone wrong?
Thanks
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
$w.onReady(function(){
$w('#register').onClick(function (){
let email = $w('#email').value;
let password = $w('#password').value;
wixUsers.register(email,password)
.then(()=>{
wixLocation.to('/create-profile');
})
})
})
You are combining two versions of code for event handlers.
$w('#register').onClick(function (){
When you add the event handler through the properties panel for that element, you automatically get an export function line of code added to your page code, like below
export function loginButton_click(event) {
Whereas, when you add the event handler into the code itself, you can simply write it like this below
$w("#registerButton").onClick( (event) => {
See here for more info about working with properties panel.
https://support.wix.com/en/article/corvid-working-with-the-properties-panel
https://support.wix.com/en/article/how-to-change-the-text-label-of-a-button-with-events
https://support.wix.com/en/article/corvid-reacting-to-user-actions-using-events
Have a look at my signup code for a custom signup lightbox.
This works perfectly for me and closes after registering details before moving user on to a signup status page, then both names will be saved in Contact List and once site member is manually approved the member details will be added to 'members' database from this tutorial here.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
import wixUsers from 'wix-users'; import wixWindow from 'wix-window'; import wixLocation from 'wix-location'; $w.onReady(function () { $w("#registerButton").onClick( (event) => { let email = $w("#email").value; let password = $w("#password").value; let first = $w("#firstName").value; let last = $w("#lastName").value; wixUsers.register(email, password, { contactInfo: { "firstName": $w('#firstName').value, "lastName": $w('#lastName').value, } } ) .then( (result) => { let resultStatus = result.status; wixWindow.lightbox.close(); wixLocation.to("/sign-in-status"); //Change the URL ending to whatever page you want to send the user to after they log in. } ); } ); });