# Different Menu for Logged-In Visitors

> Shows another navigation menu to logged-in users in the same theme location, for example with "My account" and "Log out" instead of "Sign up".

- Type: PHP
- Runs: Frontend only
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: menus, members, navigation
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/logged-in-visitors-menu/

## Code

```php
// Theme location to swap and the menu to show to logged-in users.
$wpide_member_menu_location = 'primary';
$wpide_member_menu          = 'Members Menu';

add_filter( 'wp_nav_menu_args', function ( $args ) use ( $wpide_member_menu_location, $wpide_member_menu ) {
    if ( ! is_user_logged_in() || empty( $args['theme_location'] ) || $wpide_member_menu_location !== $args['theme_location'] ) {
        return $args;
    }

    if ( wp_get_nav_menu_object( $wpide_member_menu ) ) {
        $args['menu'] = $wpide_member_menu;
    }

    return $args;
} );
```

## Notes

Create the menu under Appearance > Menus and put its name or slug in $wpide_member_menu. Works with classic themes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Different Menu for Logged-In Visitors" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
