Show Light box to visitors only.

Hello!
I have been digging through forum posts for hours now and cant seem to make any of the code work on my page…

I am adding the code on the page I want the lightbox to pop up on, not the actual lightbox page code.
I have my lightbox set to collapse on load and NO automatic display.

I would greatly appreciate any insight or tips, there has to be a way to do this. Even though many of the past posts about this didn’t really see to end up with success for anyone I still have hope!
GOAL: Light box to pop up (on this specific page, or better yet all pages) unless a member is logged in.

import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;
$w.onReady( function () {
let user = wixUsers.currentUser;
let isUserLoggedIn = user.loggedIn; // true
if (isUserLoggedIn) {
wixWindow.lightbox.close(“passwordEntry”);
} else {
wixWindow.openLightbox(“passwordEntry”);
}
});

Just use the search function in this forum and you will have found your answer already.
https://www.wix.com/corvid/forum/community-discussion/lightbox-show-hide-based-on-user-login-status

Wix already have a tutorial for a one time only lightbox too that you might be interested in.
https://support.wix.com/en/article/corvid-tutorial-creating-a-one-time-popup

WoW! Thank You! The first link is just the detail I was looking for. I had the code on the wrong page…

( I totally used the search function, found three newer threads and overlooked this one from 2018)