Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › Login Logout Menus
New Landing › How can we help? › Themeforest Theme Support › Dante › Login Logout Menus
- This topic has 18 replies, 4 voices, and was last updated 9 years by Kyle – SUPPORT.
-
Posted in: Dante
-
January 14, 2015 at 10:58 pm #141573
I currently have two menus using the function below…
function my_wp_nav_menu_args( $args = '' ) { if( is_user_logged_in() ) { $args['menu'] = 'logged-in'; } else { $args['menu'] = 'logged-out'; } return $args; } add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Unfortunately it changes all the menus including my footer menu. How can I target it so that it only targets the main menu?
Thanks in advance
January 15, 2015 at 9:05 am #141627Hi
Not sure if this will work but please can you try:
function my_wp_nav_menu_args( $args = '' ) { if( is_user_logged_in() ) { $args['main_navigation'] = 'logged-in'; } else { $args['main_navigation'] = 'logged-out'; } return $args; } add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
– Kyle
January 15, 2015 at 3:41 pm #141775Unfortunately this did not work.
January 15, 2015 at 3:44 pm #141779I will forward this to Rui to see if he knows how to do it
– Kyle
January 15, 2015 at 3:47 pm #141780If it helps I’ve been trying to use this article but none of the solutions work for Dante… http://www.wpbeginner.com/wp-themes/how-to-show-different-menus-to-logged-in-users-in-wordpress/
January 16, 2015 at 6:46 am #141915Hi,
Please try to use this code:-function my_wp_nav_menu_args( $args ) { if( 'main-navigation' == $args['theme_location'] ) { if( is_user_logged_in() ) { $args['menu'] = 'logged-in'; } else { $args['menu'] = 'logged-out'; } } return $args; } add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Hope that should work.
Thanks
MohammadJanuary 16, 2015 at 3:12 pm #142059This reply has been marked as private.January 16, 2015 at 3:55 pm #142076Hi,
That code is a bit tricky because it affects all the menus.
Other approach is to use other menu location for the logged in user.Are you using Top bar Menu? We could use that to solve this.
In the Main navigation you would put the menu for visitors an in the Top Menu Location the menu for logged in users.After that I need to add some custom code.
Let me know if it’s ok for you.
-Rui
January 19, 2015 at 5:19 pm #142485I would be fine heading down this direction as long as the top menu could be in the same spot as the main menu spot when it’s replaced.
January 19, 2015 at 6:09 pm #142493Hi,
In the file sf-header.php located in dante/includes/
find this code
$main_menu_args = array( 'echo' => false, 'theme_location' => 'main_navigation', 'walker' => new sf_mega_menu_walker, 'fallback_cb' => '', 'menu' => $page_menu );
and replace by this one
if( is_user_logged_in() ) { $main_menu_args = array( 'echo' => false, 'theme_location' => 'main_navigation', 'walker' => new sf_mega_menu_walker, 'fallback_cb' => '', 'menu' => $page_menu ); }else{ $main_menu_args = array( 'echo' => false, 'theme_location' => 'top_bar_menu', 'walker' => new sf_mega_menu_walker, 'fallback_cb' => '', 'menu' => $page_menu ); }
If the user is logged in he will see the menu associated to the Main Navigation location, but if he isn’t logged in he will see the menu associated to the Top Bar Menu Location.
Let us know the result.
-Rui
January 19, 2015 at 6:52 pm #142501I have made the requested changes but nothing has happened. I have cleared my cache as well.
January 20, 2015 at 10:17 am #142631Hi,
Strange it worked fine in my server.
Can you provide me admin access to check the file changes?-Rui
January 20, 2015 at 10:34 am #142643Hi,
Please attach a marked screenshot of your issue as you posted in first. So i can see that where is coming Menu at header and footer?
Thanks
MohammadJanuary 20, 2015 at 3:21 pm #142742This reply has been marked as private.January 20, 2015 at 3:55 pm #142757This reply has been marked as private. -
Posted in: Dante
You must be logged in and have valid license to reply to this topic.