How to create different menu’s for not logged in visitors and for logged in members?

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;

Leave a Comment