This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Creating separate main menu for logged in user, Jump Start 2.0-beta2

  • Creator
    Topic
  • #20685
    Joseph Sellers
    Participant

    Hi,

    I have been using Beta2 for quite a while and I haven’t had any problems. However, I have noticed a problem when a menu has submenus and is viewed on a mobile.

    It seems when the mobile version of the menu is used the submenus are not accessible at all.

    let me know if you need any further description or information.

    Best,

    Joseph

    P.S. I think it might be significant that I am using the ‘Entrepreneur’ theme base.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Author
    Replies
  • #20686
    Jason Bobich
    Keymaster

    @rokesmith I’m not sure I quite understand, and I haven’t had anyone else report a similar issue. Do you have a live link where I could see the issue?

    #20687
    Joseph Sellers
    Participant

    @themeblvd, I should have checked thoroughly before reporting. It was a bit of my own code which worked from the previous version of the theme.

    Here is the offending code: http://pastebin.com/2QwCbfSL

    Could you help me work out how to update this to work with the beta?

    Its purpose is just to display a different menu to logged in users and logged out users.

    #20696
    Jason Bobich
    Keymaster

    I’m not sure I understand what this would have to do with: “…mobile version of the menu is used the submenus are not accessible at all.” … or maybe I’m just not clear on what this means exactly. When your site runs, the mobile menu is simply a copy of whatever the main menu is with javascript. So, I’m not sure what you changing the name of the location has to do with this.

    It would be really helpful if you could link to a live example that shows the issue you’re having with the customization you’re trying to make.

    #20701
    Joseph Sellers
    Participant

    Yeah, I am a little confused why it should make a difference too.

    The site is https://woodworkingmasterclasses.com

    If you visit that site and squeeze the browser down to tablet size so that the mobile menu shows then there are no submenus for the ‘Gallery’ item.

    When I disabled my plugin with the hack I linked to above and enabled the same menu it worked just fine.

    #20704
    Jason Bobich
    Keymaster

    What’s the code you’re using to actually register the nav menus with WordPress? I think your issue is because you’re not using the new custom walker I wrote. So show me how you’re using register_nav_menu and I can help you to modify that.

    #20707
    Joseph Sellers
    Participant

    I believe that lines 16-27 of the pastebin above are where the menus are registered. Although it doesn’t use register_nav_menu.

    #20709
    Joseph Sellers
    Participant

    OK, I have worked out how to fix the problem. I exchanged the ‘themeblvd_primary_menu_args’ for ‘themeblvd_get_wp_nav_menu_args’.

    So, the problem is resolved but I would appreciate it if you would still look over this code and see if it is setup correctly.

    /**
     * Added by JS
     * This exchanges menus based on whether users are logged in or not
     */
    
    
    function my_primary_menu_args( $args ) {
    
    	if( is_user_logged_in() ) {
    		$args['theme_location'] = 'logged-in';
    	} else {
    		$args['theme_location'] = 'logged-out';
    	}
    
    	return $args;
    }
    add_filter('themeblvd_get_wp_nav_menu_args', 'my_primary_menu_args');
    
    
    
    /**
     * Added by JS
     * Registers two new menus. See above.
     */
    
    
    function my_nav_menus( $menus ) {
    
    	$menus = array(
    		'logged-in'		=> __( 'Logged In Menu', 'themeblvd' ),
    		'logged-out'	=> __( 'Logged Out Menu', 'themeblvd' ),
    		'footer'		=> __( 'Footer Navigation', 'themeblvd' )
    	);
    
    	return $menus;
    
    }
    add_filter( 'themeblvd_nav_menus', 'my_nav_menus' );
    #20710
    Joseph Sellers
    Participant

    Sorry, I haven’t fixed it at all. I will stop posting until you have had chance to read through what I have posted.

    However, here is a recap of what I need.

    In WPJS 1.x I had it set up to register two menu items that would be rotated depending on whether someone was logged in or out. In WPJS Beta2 this still works except that on the mobile menu the submenus are not present.

    I just want to update the bits of code I used so that they will work with 2.x

    Best,

    Joseph

    #20718
    Jason Bobich
    Keymaster

    Right now you’re filtering “themeblvd_get_wp_nav_menu_args” which doesn’t exist any more. So that entire function you have there swapping the menus on the frontend isn’t actually doing anything at all. So, if you notice when you view your site, you always see the “logged-in” menu, no matter what. The theme is trying to pull location “primary” but since you’ve removed it, it’s pulling the first menu you registered which is “logged-in”.

    So, I believe this:

    add_filter('themeblvd_get_wp_nav_menu_args', 'my_primary_menu_args');

    Should now be this:

    add_filter('themeblvd_primary_menu_args', 'my_primary_menu_args');

    Does that fix it?

    #20719
    Jason Bobich
    Keymaster

    … but unfortunately this I think will just fix the problem you weren’t aware of. But I think you’re still going to have the same issue you originally posted about. Because the menu checks for the “primary” menu location (which you’re changing) before adding the toggle icons for mobile. I’ll see if I can add a filter that allows what you’re trying to do for the next update.

    #20720
    Jason Bobich
    Keymaster

    Ok, I’ve got in there for the next update. After the next update, here’s the code you’ll use:

    /**
     * Added by JS
     * This exchanges menus based on whether users are logged in or not
     */
    function my_primary_menu_location( $menu ) {
    
    	if( is_user_logged_in() ) {
    		$menu = 'logged-in';
    	} else {
    		$menu = 'logged-out';
    	}
    
    	return $menu;
    }
    add_filter('themeblvd_primary_menu_location', 'my_primary_menu_location');
    
    /**
     * Added by JS
     * Registers two new menus. See above.
     */
    function my_nav_menus( $menus ) {
    
    	$menus = array(
    		'logged-in'		=> __( 'Logged In Menu', 'themeblvd' ),
    		'logged-out'	=> __( 'Logged Out Menu', 'themeblvd' ),
    		'footer'		=> __( 'Footer Navigation', 'themeblvd' )
    	);
    
    	return $menus;
    
    }
    add_filter('themeblvd_nav_menus', 'my_nav_menus');
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.