Site logo

[Resolved] Exclude menus for logged out users on all pages

Home Forums Support [Resolved] Exclude menus for logged out users on all pages

Home Forums Support Exclude menus for logged out users on all pages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2527055
    Carsten

    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

    #2527431
    David
    Staff
    Customer Support

    Hi there,

    do you want to unhook the entire navigation if the user is logged out ?

    #2527583
    Carsten

    Yes, that would work, as long as the mobile menu svg will be unhooked as well.

    Thanks

    #2527665
    Ying
    Staff
    Customer Support

    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 '';
    } );
    #2527699
    Carsten

    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.

    #2527758
    Ying
    Staff
    Customer Support

    Awesome, glad it works for you 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.