Hi everyone!
I’m making a website that involves showcasing some of my movies and shorts. I put the videos on a separate lightbox for each them individually. Thing is, some content I want them to be unable to view without signing up. Is there any way to trigger this like a regular members only page would?
Cheers!
If → Members only → then it comes always to the use case, using the ID of the current logged-In user.
But wait, normaly you don’t even need any codings, as i assume it…
Take a look onto your page-settings…you will find something like…
Now you can create one page for normal users and one for registered ones.
Yeah but that’s for an entire page. I just need a “members-only” option for a lightbox.
Than you will need to use code.
- You will need to be able to detect logged-in-users getting their IDs, for example.
- You will need to generate an if-else-query, to show/hide wished elements, regarding the current loggin-situation of the currrent logged or not logged-in user.
My suggestion would be the following…
- Open the following API-REFERENCE…
https://www.wix.com/velo/reference/wix-members/authentication/onlogin
…and put some console-logs onto your code, to be able to inspect the results.
You should normaly recognice emmidiately when a user is logged-in or not.
When you know how to differ between the two states (logged-in and not logged-in) you just simply create your IF-ELSE-STATEMENT, which would be something like…
if (the current user is logged in) {show elements A-C-D-G}
else {show elements B-E-F on my page}
let us say you declared a → login-state: (legged-in = true / logged-out = false)
let loginState = TRUE
simple-example:
let loginState = true;
if(loginState===true) {$w('#myElement').show();}
else {$w('#myElement').hide();}
Also read this one! → https://www.wix.com/velo/forum/coding-with-velo/wixmember-not-working-after-initial-login-until-refresh
Because there was an update in the past few weeks on Wix-Side → a new API was rolled-out, the API is not 100% fixed. Just wanted to let you know about this.
But in General it should work for you.
Collect all needed information from the given links and try to generate your wished function.
If you still have problems, do not hesitate to aks for more help.
BUT FIRST TRY IT ON YOUR OWN!
Good luck!