WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display separate menus for custom user roles (1 post)

  1. DesignLoud
    Member
    Posted 1 year ago #

    Hi all, I need some help trouble shooting. I want to be able to display different menus depending on the user role. I am modifying the Repro theme from ThemeZilla. From what I can see I have everything setup correctly but cant get it to display the specified menu when logged in as that user role. I have already setup the menus in the backend and assigned the proper menus. Any help would be greatly appreciated.

    <div id="second_nav">
    					<?php if (current_user_can('Bb_Rebellion_Hitting')){
        //menu for hitters role
    	wp_nav_menu( array( 'theme_location' => 'members-hitting-menu', 'menu_class' => 'sf-menu', 'container' => '' ) );
    
    }elseif(current_user_can('Bb_Rebellion_Pitching')){
        //menu for pitchers role
    	wp_nav_menu( array( 'theme_location' => 'members-pitching-menu', 'menu_class' => 'sf-menu', 'container' => '' ) );
    
    }else{
        //default menu
        if ( has_nav_menu( 'secondary-menu' ) ) : /* if menu location 'secondary-menu' exists then use custom menu */ ?>
    					<?php wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'menu_class' => 'sf-menu', 'container' => '' ) ); ?>
    					<?php else: /* else use wp_page_menu
    					if the home link is set to true in theme options then show "home" button
    					if excluded categories are set in theme options then exclude from menu */
    
    					$tz_home_link = get_option('tz_home_link');
    					$tz_nav_exclude = get_option('tz_nav_exclude');
    					$tz_nav_order  = get_option('tz_nav_order'); 
    
    					?>
                        <ul class="sf-menu">
    
                        	<?php if ($tz_home_link == "true") : ?>
                        	<li><a href="<?php bloginfo('url'); ?>"><?php _e('Home', 'framework'); ?></a></li>
                            <?php endif; ?>
    
                            <?php wp_list_pages( array( 'exclude' => $tz_nav_exclude, 'title_li' => '', 'sort_column' => $tz_nav_order, )); ?>
    
                        </ul>
                        <?php endif; ?>
    
                    </div><!--second_nav-->
    <?php }                ?>

Topic Closed

This topic has been closed to new replies.

About this Topic