Skip to content

create a menu visible only to logged‑in users

To create a menu visible only to logged‑in users…and show a different menu to the public, the key idea is:

  • Public users → see Menu A
  • Logged‑in Premium users → see Menu B

You can achieve this using:

  1. User roles (best if Premium users have a special role)
  2. Membership plugins (MemberPress, Paid Memberships Pro, WooCommerce Memberships, etc.)
  3. Code-based menu switching (lightweight and flexible)

Let’s go through the simplest and most powerful method.


Method 1 — Use WordPress roles + conditional menus (recommended)

If your Premium users have a special role (e.g., premium, subscriber_plus, etc.), you can conditionally load a different menu.

Step 1 — Create two menus

  • Menu Public
  • Menu Premium

Step 2 — Add this code to functions.php or Code Snippets:

function custom_menu_for_premium_users( $args ) {
    // Replace 'premium' with your actual role name
    if ( is_user_logged_in() && current_user_can( 'premium' ) ) {
        if ( $args['theme_location'] === 'primary' ) {
            $args['menu'] = 'Menu Premium'; // name or ID of your premium menu
        }
    }
    return $args;
}
add_filter( 'wp_nav_menu_args', 'custom_menu_for_premium_users' );

Result

  • Logged‑in Premium users see Menu Premium
  • Everyone else sees Menu Public

This is lightweight, fast, and doesn’t require plugins.


Method 2 — Use a membership plugin (no code)

If you’re using:

  • MemberPress
  • Paid Memberships Pro
  • WooCommerce Memberships
  • Restrict Content Pro

…these plugins let you restrict menu items or entire menus based on membership level.

See also  How to change the admin login URL in WordPress website to improve security?

You simply:

  1. Edit a menu item
  2. Choose “Visible to: Premium Members Only”
  3. Save

This is the easiest if you already use a membership system.


Method 3 — Use the “If Menu” plugin (simple, no coding)

Install:

If Menu – Visibility control for menu items

Then you can set conditions like:

  • “Show only if user is logged in”
  • “Show only if user has role Premium”
  • “Hide if user is logged out”

This works well for small sites.

Leave a Reply

error: Content is protected !!