- This topic has 3 replies, 2 voices, and was last updated 6 years, 5 months ago by
David.
-
AuthorPosts
-
November 8, 2019 at 1:18 am #1056618
Gilles
Hello
I can not fix a problem with the secondary menu.
This menu should only appear for logged in users. For that I use the plugin ifmenu (https://fr.wordpress.org/plugins/if-menu/): https://i.imgur.com/5pe09Vr.jpg
It’s OK on Destock Device: https://i.imgur.com/lRuUfgk.jpg
But, on mobile device, secondary menu appears (but is inactive) as you can see here (https://i.imgur.com/BpQdylT.png) even if user is not logged in …
I would like it not to appear on a mobile device if the user is not logged in (But that it appears well if it is connected… so I can’t use mobile restriction with ifmenu )
Could you help me ?
Thank you
Regards
Gilles DubusNovember 8, 2019 at 3:36 am #1056733David
StaffCustomer SupportHi there,
If Menu only removes the menu items themselves not the container.
Two options:1. Some CSS to hide the secondary nav container on mobile:
@media (max-width: 768px) { .secondary-navigation { display: none; } }2. If it is the entire navigation that should only be visible to logged in users then you can remove IF Menu and instead use the Layout Element to Disable the secondary navigation. Within the Display Rules you can set Logged Out users.
November 8, 2019 at 4:41 am #1056775Gilles
Thank you for your answer David.
1) The secondary menu must be visible to logged in users, so it is not suitable.
2) I don’t understand how to do it…But never find… I finally found the solution in your documentation : https://docs.generatepress.com/article/show-secondary-navigation-to-logged-in-users-only/ :
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;
}
I put this code in the theme functions.php file and it works perfectly.Best regards
GillesNovember 8, 2019 at 4:45 am #1056780David
StaffCustomer SupportTo explain 2:
Using the Layout Element:
https://docs.generatepress.com/article/layout-element-overview/You can Disable Secondary Navigation then in your Display Rules set it to logged out users. This will then remove the nav for any logged out user.
Which is doing exactly what that PHP filter snippet is doing 🙂
Glad you found the solution
-
AuthorPosts
- You must be logged in to reply to this topic.