0

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

2
  • "use is_user_logged_in conditional tag and apply a different menu accordingly" Cool, but where do I put this?
    – Gediminas
    Mar 4, 2012 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, 2012 at 1:02

1 Answer 1

4

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');
endif;
5
  • Dammit, just beat me to that exact same answer. Upvoted.
    – Chris Cox
    Mar 4, 2012 at 13:20
  • But where do I put this code in?
    – Gediminas
    Mar 4, 2012 at 14:38
  • @hannit_cohen where would I put this code in? I have a child theme, if that helps.
    – Gediminas
    Mar 4, 2012 at 15:14
  • Added the required code upside Mar 5, 2012 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. Mar 5, 2012 at 14:21

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.