Support » Plugins » Hacks » Menu (registered user detection within menu)

  • Hi, I would like to detect registered users within menu – use function
    <?php if ( is_user_logged_in() ) { ... } ?> and display menu just for them (User that is not logged will see just link to log in).
    I have tried using my theme code like that:

    <?php if ( is_user_logged_in() ) {
    <?php $menuClass = 'nav';
    					$menuID = 'top-menu';
    					$primaryNav = '';
    					if (function_exists('wp_nav_menu')) {
    						$primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => $menuID, 'echo' => false ) );
    					};
    					if ($primaryNav == '') { ?>
    						<ul id="<?php echo $menuID; ?>" class="<?php echo $menuClass; ?>">
    							<?php if (get_option('modest_home_link') == 'on') { ?>
    								<li <?php if (is_home()) echo('class="current_page_item"') ?>><a href="<?php bloginfo('url'); ?>"><?php esc_html_e('Home','Modest') ?></a></li>
    							<?php } ?>
    
    							<?php show_page_menu($menuClass,false,false); ?>
    							<?php show_categories_menu($menuClass,false); ?>
    						</ul> <!-- end ul#nav -->
    					<?php }	else echo($primaryNav); ?>
    } ?>

    but it doesn’t work :/, any idea?
    Thank You

  • The topic ‘Menu (registered user detection within menu)’ is closed to new replies.