• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to change the menu if the visitor is connected

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to change the menu if the visitor is connected

This topic is: resolved
  • This topic has 6 replies, 2 voices, and was last updated 8 years, 6 months ago by JanHoek.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • August 9, 2014 at 12:42 pm #117949
    Julien
    Member

    Hello,

    All is in the title - I think -. I'm running a membership oriented website (using amember.com) and I need to provide a different menu if the visitor is connected. I'm confortable with PHP coding. But I'd like some guidance on how to do it properly. Could someone help ?

    Thx

    PS : I'm using News Pro

    August 9, 2014 at 1:59 pm #117981
    JanHoek
    Participant

    Create a 2 different menus > logged-in and logged-out

    Then add th following to your functions.php

    function my_wp_nav_menu_args( $args = '' ) {

    if( is_user_logged_in() ) {
        $args['menu'] = 'logged-in';
    } else {
        $args['menu'] = 'logged-out';
    }
        return $args;
    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

    I hope this works for you


    Hi, my name is Jan Hoek. Sure, they all say I have a big head, but I like to think it’s way too small for all my ideas.

    August 10, 2014 at 8:15 am #118049
    Julien
    Member

    It sure (mostly) does, thank you. There's just one issue : it changed my two menus (primary & secondary). How could I change only the one I need ?

    August 10, 2014 at 8:20 am #118051
    JanHoek
    Participant

    Explain it a bit better, I'm not sure what you mean. 🙂


    Hi, my name is Jan Hoek. Sure, they all say I have a big head, but I like to think it’s way too small for all my ideas.

    August 10, 2014 at 8:22 am #118052
    Julien
    Member

    found it sorry, it was obvious 🙂
    thx again

    August 10, 2014 at 8:28 am #118058
    Julien
    Member

    I meant it was changing both my primary AND my secondary menu. I wanted to change only my secondary menu. I just added a if('secondary' == $args['theme_location'])

    August 10, 2014 at 8:33 am #118064
    JanHoek
    Participant

    Super. Glad I could help. Please close this post if it's solved. Good luck.


    Hi, my name is Jan Hoek. Sure, they all say I have a big head, but I like to think it’s way too small for all my ideas.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble