Hi,
I am trying to set a 'My Account' button to send my user to their member page if they are already logged in; if they aren't, I want my custom login Lightbox to appear.
I have managed to successfully make the if/else statement work, when the outcome was to go to a page. However, I cannot seem to make the Lightbox open.
This is what I have so far:
import wixWindow from 'wix-window';
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn;
export function button37_click(event) { if (isLoggedIn) { wixLocation.to('/real-shop'); } else wixWindow.openlightbox("login"); }
For clarification:
'button37' is the aformentioned 'My Account' button, I have just not changed the name.
I have used the page extension 'real-shop' as an example, as I am yet to make my members page.
I have made the Lightbox name simply 'Login', as I thought that is where I was going wrong but it seems not.
If anyone could point out my mistake I would be very grateful!
Many thanks,
Ben
Is your lightbox called 'Login' or 'login'?
If it is 'Login', then that needs to be reflected in your code.
wixWindow.openLightbox("Login");
if it is 'login', then that needs to be reflected in your code.
wixWindow.openLightbox("login");
Are you just trying to do something like this?
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
Also, where is your onReady function underneath your imports?
https://www.wix.com/corvid/reference/$w.html#onReady