Okay
  Public Ticket #833398
Changing Top menu after logging in
Closed

Comments

  • Onyx started the conversation

    We want to change the top menu after login such that the menu title changes to Hello, "username" and the dropdown of the top menu should also change. However when we implement this code "

    function my_wp_nav_menu_args( $args = '' ) {

        if( is_user_logged_in() ) {

            $args['menu'] = 'logged-in';

        } else {         $args['menu'] = 'topleft';

    }

            return $args;

        }

        add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

    "  it also changes the brand/primary menu. Please get back to us ASAP. Thankyou :)

  • [deleted] replied

    Hi Onyx,

    The code you have added will be applied for all menus, however you can add the same code it this way (modified slightly):

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

    Hopefully this will work for you.