Different Logged in Top Menu

Home Forums Spacious Free Different Logged in Top Menu

This topic contains 3 replies, has 2 voices, and was last updated by  Bipin Singh 4 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #238809

    alynasir
    Participant

    Hi, I am trying out this code to get a different main menu for logged in users,

    function my_wp_nav_menu_args( $CSMenu = '' ) {
    
    if( is_user_logged_in() ) { 
    	$CSMenu['menu'] = 'User-Menu';
    } else { 
    	$CSMenu['menu'] = 'Main-Menu';
    } 
    	return $CSMenu;
    }
    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

    However using the above code changes the footer menu too. How can I refer only to the top menu and stop the footer menu from changing as well.
    Regards,
    Ali

    #242190

    Bipin Singh
    Moderator

    Hi,

    We only give support regarding our theme, not to third party plugins and personal customization.
    However, I have done some research on it and let me provide some help to you . So, here’s the code:
    Replace your code with the following:

    function my_wp_nav_menu_args( $CSMenu = '' ) {
    
    if( 'primary' == $CSMenu['theme_location'] ) {
    if( is_user_logged_in() ) { 
    	$CSMenu['menu'] = 'User-Menu';
    } else { 
    	$CSMenu['menu'] = 'Main-Menu';
    }
    } 
    	return $CSMenu;
    }
    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

    Hope this helps.
    Also, if you feel that our help needs some favor to return than you can do it by rating our theme in WordPress repo here:
    https://wordpress.org/support/view/theme-reviews/spacious

    #243740

    alynasir
    Participant

    Wow, thank you very much. The code you provided works perfectly.

    I was trying to get over the problem and not being a coder by nature or profession, searching online did not help me much. I had hit a brick wall and was going to give up my pursue. I considered contacting you people as a last resort and thought I had a very low chance of getting anything.

    However, I had forgotten that there are still businesses which provide great services and go beyond what is required from them to help others. Your free support is much better than the paid “pro” support I get from else where. Your theme is rock solid, well designed and looks great. I also really appreciate your company offering it for free.

    Thank you once again and I will surely rate your theme on the provided link.

    Sincerely,
    Ali

    #247117

    Bipin Singh
    Moderator

    Hi alynasir,

    Thanks for rating and wonderful remark in WordPress repo.
    We really appreciate it, Delighted. 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.