board logo
Posted by: DogMan - 03 April 2026 14:05:06
How can I have two different menus in wordpress for whether a user is logged in or not?

Posted by: sirclesadmin - 03 April 2026 14:06:20

Since you are already using GeoDirectory and AyeCode Connect, you have a few ways to handle this. You can either swap the entire menu or just hide/show specific links within a single menu.

Here are the three best ways to do it:

1. Using a Plugin (The "No-Code" Way)

The most popular and reliable plugin for this is Conditional Menus (by Themify).

  • How it works: You create two separate menus in Appearance > Menus (e.g., "Logged In Menu" and "Logged Out Menu").
  • Setup: Under the Manage Locations tab in the Menus screen, you'll see your primary menu location. Click "Conditional Menu," select your "Logged In Menu," and set the condition to "User is logged in."
  • Result: WordPress will automatically swap the entire menu based on the user's status.

2. Using "If Menu" (To keep one menu but hide items)

If you only want to change 1 or 2 items (like swapping "Login" for "My Dashboard"), the If Menu plugin is better.

  • Once installed, go to your existing menu.
  • Expand a menu item (like "Add Listing").
  • Check the box "Enable visibility rules."
  • Select Show if User is Logged In.
  • This keeps your menu management simple as you only maintain one list.

3. Using a Code Snippet (Lightweight & Clean)

If you prefer not to add another plugin, you can add this to your theme's functions.php file. This tells WordPress to look for a specific menu name based on the user's status.

function my_wp_nav_menu_args( $args = '' ) {
    // Check if it's the Primary Menu location
    if( $args['theme_location'] == 'primary' ) { 
        if( is_user_logged_in() ) { 
            $args['menu'] = 'Logged In Menu';
        } else { 
            $args['menu'] = 'Logged Out Menu';
        } 
    }
    return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

> Note: Make sure the names 'Logged In Menu' and 'Logged Out Menu' exactly match the names you gave your menus in the WordPress settings.

Which should you choose?

  • Choose Option 1 if the two menus are completely different (e.g., a member portal vs. a marketing site).
  • Choose Option 2 if the menus are 90% the same and you just want to hide the "Login" button once they are inside.
  • Choose Option 3 if you want to keep your site as fast as possible by avoiding extra plugins.

Since you've got GeoDirectory running, you might also check your UsersWP settings (if you have that installed)-it often has built-in options to toggle login/logout links automatically!

Do you want the entire menu to change, or are you just looking to swap out a couple of specific links?