How can i change my front end menu depending on if the user is logged in or not?

For Example:

View 1: user is not logged in
menu is : home , about us, testimonials

View 2: user is logged in
menu is : dashboard, my profile, support

Thanks in advance.

1 Answer 1


Define two menus and serve them based on if they are logged in or not which you can do in your theme's functions.php file:

if (is_user_logged_in()){
  wp_nav_menu( array(
    'menu'            => 'Logged In Menu',
    'container_class' => 'logged-in-menu',
    'theme_location'  => 'logged-in'
} else {
  wp_nav_menu( array(
    'menu'            => 'Visitor Menu',
    'container_class' => 'visitor-menu',
    'theme_location'  => 'visitor'

You'll also need to register their theme locations which you can do in your theme's functions.php file as well:

register_nav_menus( array(
  'logged-in'  => __( 'Logged-in Menu Area',  'yourtheme' ),
  'visitor' => __( 'Visitor Menu Area', 'yourtheme' ),

And you'll have to assign those menus to their menu locations in the admin, like so:

WordPress Admin Menu Locations

  • Thank you, Mike. What did you mean by "register their theme locations"? I am using the twentyten theme. What would I put for 'yourtheme'?
    – rexposadas
    Jan 28, 2011 at 21:42
  • @rxn - "Register theme locations" means call register_nav_menus() as I showed in code above. As for your theme, create a child theme of TwentyTen instead of using it directly and then put the directory name of your child theme in place of 'yourtheme' "Customizing a WordPress theme without changing it?" wordpress.stackexchange.com/questions/290/… Jan 29, 2011 at 1:55
  • Thank You for putting in the time to answer my question in great detail.
    – rexposadas
    Jan 31, 2011 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.