This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Need to hide menu item on specific page based on session variable

Resolved 4 replies generaltechnical
9 years ago · Last reply by Alex S 9 years ago

Hi ,

I am very new and trying to learn web site making on my own. I am using Vantage- free theme. I need to hide menu in specific page only based on if user is logged in or not.
Adding below in style.css make the menu item hidden always but I need to make it hidden based session variable $_SESSION[‘username’]. Please help!

.page-id-32 #menu-secondary-menu #menu-item-162 {
display: none;
}

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

4
  1. Alex S Staff 9 years, 8 months ago

    Hi Seema,

    Just to clarify, are you trying to hide it based on a specific username or is it for any logged in user? If it’s the latter, you should use is_user_logged_in(). You should also avoid using direct session variables. You should use wp_get_current_user() instead for getting the username.

  2. Alex S Staff 9 years, 8 months ago

    Hi Seema,

    Also, just as a heads up; if you’re making direct edits to the core template files your changes will be lost on update. You should be using a child theme when making changes to theme files. Here’s a basic child theme for Vantage already set up.

  3. Seema 9 years, 7 months ago

    Hi Alex,

    I want to hide/show menu based on specific user types . example my site has only 2 types of user “customer” & “vendor”. during login validation I m storing the user types in a session variables when user logged in successfully. Please help

    Thanks,
    Seema

  4. Alex S Staff 9 years, 7 months ago

    Hi Seema,

    I personally would recommend against using session variables in the manner you’re using (as it’s unnecessary) and would instead recommend using current_user_can().

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread