Archived topic
Exclude menus for logged out users on all pages
5 replies · Started by Carsten on February 9, 2023
Hi there, I have an issue with an empty menu, only on mobile.
It's empty because I use a plugin to display menu items to only logged in users, and the rest of the menu items are for logged in BuddyPress members.
So the goal is use a conditional tag to hide the menu for all logged out users on all pages, without using a layout element.
But there are som weird things going on.
1. the menu is displayed on mobile only on all other pages than the frontpage, even though I have no layout element active or hided it with css.
Desktop
https://imgur.com/z8iR7Ae
Mobile
https://imgur.com/xxPfl0X
Open
https://imgur.com/63qD4X4
2. not on frontpage on neither mobile or desktop
Desktop
https://imgur.com/7l6D2NN
Mobile
https://imgur.com/8sS7KtU
There are som padding added so the header is displayed, even without content, but I can't se any .inside-header code in my custom css, is this padding added pr default?
Regards
Carsten
Hi there,
do you want to unhook the entire navigation if the user is logged out ?
Yes, that would work, as long as the mobile menu svg will be unhooked as well.
Thanks
Hi Carsten,
Try this PHP snippet:
add_filter( 'generate_navigation_location', function(){
if ( is_user_logged_in()) {
return generate_get_option( 'nav_position_setting' );
}
return '';
} );
Hi Ying, that's perfect - the mobile menu svg has gone, and now I don't even need the user menu plugin anymore, thats one plugin less;-)
Thank you.
Awesome, glad it works for you :)