Show menu item after log in

Joined
Aug 21, 2023
Messages
42
Reaction score
0
Hi everyone,
I have a wix site and I want to show a header menu link after log in and to be hidden by default. It seems that this is not possible but I heard with some coding this can be done by something like hide menu1, show menu2 after log in... Can this be done in javascript alone? I would appreciate your help.
Thanks.
 
Joined
Jul 7, 2024
Messages
4
Reaction score
0
You can’t do this with plain JavaScript on Wix, because you don’t have direct access to the header/menu DOM the way you would on a normal custom site. On Wix you need to use Velo (their built-in dev tools).


Example
Code:
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';


$w.onReady(function () {
  if (wixUsers.currentUser.loggedIn) {
    $w("#menuItemLoggedIn").show();
  } else {
    $w("#menuItemLoggedIn").hide();
  }
});

Add an element (button/link/menu item) in your header and give it an ID like #menuItemLoggedIn.
By default, set it to hidden on load.
Then the code checks if the user is logged in and shows it.


So no, it’s not just raw JS, but with Velo you can control visibility based on login status pretty easily.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top