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;
}
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.
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.
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
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().