Hello! I have created a custom member profile and update page using this tutorial: [Velo Tutorial: Building Your Own Members Area | Help Center | Wix.com…](Velo Tutorial: Building Your Own Members Area | Help Center | Wix.com…
)
I have separately created a custom registration page, and a custom login lightbox. Registration is working. I have yet to be able to test the login page, as I’m encountering issues. The login button as created following the above tutorial doesn’t trigger anything.
I would like the login button on my /login page to trigger the lightbox opening.
So I have two questions: Are there issues in my existing code, and where/how should I insert code to trigger the lightbox?
Registration Page: www.fineartprintfair.org/login
Login Page: www.fineartprintfair.org/register
Login Page Code:
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#loginButton").label = "Logout";
$w("#myBoothButton").show();
$w("#registerButton").hide();
} else {
$w("#loginButton").label = "Login";
$w("#myBoothButton").hide();
$w('#registerButton').show();
}
} );
/**
* Adds an event handler that runs when the element is clicked.
* @param {$w.MouseEvent} event
*/
export function loginButton_click(event) {export function loginButton_click(event) {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w("#loginButton").label = "Login";
$w("#myBoothButton").hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("Members")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("Members", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#loginButton").label = "Logout";
$w("#myBoothButton").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
}
/**
* Adds an event handler that runs when the element is clicked.
* @param {$w.MouseEvent} event
*/
export function myBoothButton_click(event) {export function myBoothButton_click(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.id}`);
}
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
}