Archived topic
Show Secondary Menu to Logged in Users – Conditional Logic
3 replies · Started by Maria on August 8, 2018
Viewing posts 1–4 of 4
What function do I use to show the secondary menu to logged-in users? I can only figure out this much: <?php
if ( is_user_logged_in() ) {
Try this function:
add_filter( 'has_nav_menu', 'tu_disable_secondary_nav_logged_out', 10, 2 );
function tu_disable_secondary_nav_logged_out( $has_nav_menu, $location ) {
if ( 'secondary' === $location && ! is_user_logged_in() ) {
return false;
}
return $has_nav_menu;
}
Let me know :)
Awesome! Thanks so much. I was way off!
You're welcome! :)
This archived topic is closed to new replies.