Lightbox show/hide based on user login status

I have a lightbox for getting subscribers and for welcoming website new comers. I would light for these boxes to not pop up if the site member is logged in. Can anyone help?

Hey there,

You’ll want to check the loggedIn property of of the currentUser . If the user is not logged in, use the openLightbox function to show the lightbox.

so this is the code i have listed in my home page where the welcome lightbox pops up…

import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;

$w.onReady( () => {

if(wixUsers.currentUser.loggedIn) {
wixWindow.lightbox.close();
}
else {
wixWindow.openLightbox(‘Welcome’).then(dataObj => {
console.log(dataObj);
} );

actually this is what i have so far

import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;

$w.onReady(() => {

if (wixUsers.currentUser.loggedIn) { 
	wixWindow.lightbox.close(); 
} else { 
	wixWindow.openLightbox("Welcome"); 
} 

});

so i figured it out!
The following code goes in the page code for the lightbox it’s self…

import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;

$w.onReady(() => {

if (wixUsers.currentUser.loggedIn) { 
	wixWindow.lightbox.close('Welcome'); 
} else { 
	wixWindow.openLightbox('Welcome'); 
} 

});

then set the lightbox to open automatically from the lightbox settings screen… the lightbox will set to open auto if the user is not logged in and will not open if the user is logged in

This worked for me. I just added it to the body-end part of the page that the lightbox appears on. Thank you!