Coding help: Connecting switch to active lightbox

I added a switch to a page. I need the code that I can connect to the switch to basically say:
if the switch is on = activate this pre-designed Lightbox for all users on the site
if the switch is off = disable this pre-designed Lightbox for all users on the site

Not sure what you mean by “all users of the site”. On what page will the switch be? If it’s on an admin page, then you can save the value of the switch in a database collection that you use for admin configuration information.

Wherever it is you open the Lightbox, you just need to check the status of the value in the collection. You need to query the database for the field, and then based on the value, you can then open the Lightbox.

if(switchValue === true) {
        wixWindow.openLightbox("LightboxName");
}