I'm creating a website which will provide services to members and I want to make it so that when a not logged in person comes to the website the menu is specifically designed for sales pages to make him register, but when a logged in person comes in he sees a different menu that is for the sole purpose of delivering the services. I want to make this because I don't want my already members always going to the website to read the sales pages. I would so appreciate your help, just can't figure this out on my own. And I think this would be pretty neat also :) hoping for an answer

  • "use is_user_logged_in conditional tag and apply a different menu accordingly" Cool, but where do I put this? – Gediminas Mar 4 '12 at 15:05
  • Search your themes templates until you find your menu. Then alter this with the code mentioned in the answer below. – kaiser Mar 5 '12 at 1:02

You can do that by using 2 different menus (wp_nav_menu).

use is_user_logged_in conditional tag and apply a different menu accordingly:

if (is_user_logged_in()) {
      wp_nav_menu(array('theme_location' => 'logged_user' ));
} else {
      wp_nav_menu(array('theme_location' => 'new_user' ));

Edit This code goes where you'd usually put your regular menu in the theme - probably header.php

Also, make sure that you add the menus to the actual theme, i.e. in function.php add the folowing lines of code:

if (function_exists('register_nav_menu')):
    register_nav_menu('logged_user', 'Existing users menu');
    register_nav_menu('new_user', 'New users menu');
  • Dammit, just beat me to that exact same answer. Upvoted. – Chris Cox Mar 4 '12 at 13:20
  • But where do I put this code in? – Gediminas Mar 4 '12 at 14:38
  • @hannit_cohen where would I put this code in? I have a child theme, if that helps. – Gediminas Mar 4 '12 at 15:14
  • Added the required code upside – hannit cohen Mar 5 '12 at 13:31
  • 1
    "But where do I put this code in?" only you can answer that question, as it is entirely dependent upon your Theme. See the wp_nav_menu() Codex entry that @hannitcohen linked in his answer. – Chip Bennett Mar 5 '12 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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