• Plans & Pricing
  • Log in
  • Get started
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress 
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Get started
  • Sign up
  • Log in
About
  • Plans & Pricing
Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress  
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Jetpack App
  • Learn more
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Search
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Forums / how to show different menus when user is logged in and when not

how to show different menus when user is logged in and when not

  • Unknown's avatar
    amerzsa · Member · May 11, 2011 at 10:35 am
    • Copy link Copy link
    • Add topic to favorites Add topic to favorites

    Hi,

    I’m new in wordpress and I wan’t to tweak my theme to show different menus
    when user is logged in and logged out.
    I found somewhere on internet that I should put this in functions.php:

    register_nav_menus( array(
    ‘primary’ => __( ‘Primary Navigation Area’, ‘twentyten’ ),
    ‘logged_out’ => __(‘Logged Out Area’, ‘twentyten’ )
    ) );

    and

    if (is_user_logged_in() || current_user_can(‘level_10’)){
    wp_nav_menu( array(
    ‘menu’ => ‘Primary Navigation’,
    ‘container_class’ => ‘primary-navigation’,
    ‘theme_location’ => ‘primary’
    ));
    } else {
    wp_nav_menu( array(
    ‘menu’ => ‘Logged Out’,
    ‘container_class’ => ‘logged-out’,
    ‘theme_location’ => ‘logged_out’
    ));
    };

    But when I log out from admin it shows me a bunch of warning, for example:

    Warning: Cannot modify header information – headers already sent by (output started at E:xampphtdocswordpresswp-includesnav-menu-template.php:235) in E:xampphtdocswordpresswp-login.php on line 354

    Warning: Cannot modify header information – headers already sent by (output started at E:xampphtdocswordpresswp-includesnav-menu-template.php:235) in E:xampphtdocswordpresswp-login.php on line 366

    Can you please give me very detail explanation (step-by-step) how to show different menus when user logged in and not?

    Thanks in advance,

    Amer

  • Unknown's avatar
    supportbot · Member · May 11, 2011 at 10:35 am
    • Copy link Copy link

    You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.

    If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.

    This is an automated message.

  • The topic ‘how to show different menus when user is logged in and when not’ is closed to new replies.

Tags

  • menu login logout

About this topic

  • In: Support
  • 2 participants
  • 1 reply
  • Last activity 15 years
  • Latest reply from amerzsa

Have a question?

Get in touch

Couldn't find what you needed?

Contact us

Get answers from our AI assistant, with access to 24/7 expert human support on paid plans.

Browse our guides

Find step-by-step solutions to common questions in our comprehensive guides.

WordPress.com

Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Professional Email
  • Website Design Services
  • WordPress Studio
  • Enterprise WordPress
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • WordPress.com Blog
  • Business Name Generator
  • Logo Maker
  • WordPress.com Reader
  • Accessibility
  • Remove Subscriptions
Help
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
  • Developer Resources
Company
  • About
  • Press
  • Terms of Service
  • Privacy Policy
  • Do Not Sell or Share My Personal Information
  • Privacy Notice for California Users
DeutschEspañolFrançaisBahasa IndonesiaItalianoNederlandsPortuguês do BrasilSvenskaTürkçeРусскийالعربيةעִבְרִית日本語한국어简体中文繁體中文English

Mobile Apps

  • Download on the App Store
  • Get it on Google Play

Social Media

  • WordPress.com on Facebook
  • WordPress.com on X (Twitter)
  • WordPress.com on Instagram
  • WordPress.com on YouTube

Automattic

Automattic
Work With Us
    • WordPress.com Forums
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions