Lightbox for visitors only

Hi,

I have a lightbox that pops up when the page loads.
How can I make it pop up for visitors only? (non-members).

Thanks,
#lightbox , #members

Put a simple code on your page that checks if the user is logged in as a member or not, if they are not logged in then you can set the lightbox to open and be shown and closed if they are members.
https://www.wix.com/corvid/reference/wix-users.User.html

Thanks for the swift answer, my coding skills are limited tho, do you have an example I could copy/paste by any chance?

@hello37231 See the example in the loggedIn property docs.

@yisrael-wix & Thanks heaps for your help… I’ve tried with the following but seems I’m still missing something for it to work properly…?

import {session} from ‘wix-storage’;
import wixWindow from ‘wix-window’;
import wixUsers from ‘wix-users’;

const user = wixUsers.currentUser;

const userId = user.id;
const isLoggedIn = user.loggedIn;

$w.onReady( function () {
// user is not logged in
if (!isLoggedIn) {
// open popup
wixWindow.openLightbox(“lightbox1”);
}
});

@hello37231 Check that isLoggedIn is working as expected with console.log but my suspicion is that your lightbox isn’t called that. Use its exact title as shown in the menu editor, not the properties panel.

Many thanks for your help guys… I think I’m almost there.

I got the below code checked by a coder who told me it was working fine but it seems that Wix lightbox is triggered by something else as the code is not running properly based on if user is logged in or not…

Has anyone got any insight on this one?