I want to display a different menu depending whether a user is logged into the CMS or not.
I'm using this for my menu:
<?php if ( is_user_logged_in() ) {
$args = array(
'depth' => 1,
'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0,
'exclude' => '5, 80, 83, 138',
'include' => '',
'title_li' => __(''),
'echo' => 1,
'authors' => '',
'sort_column' => 'menu_order, post_title',
'link_before' => '',
'link_after' => '',
'walker' => '' );
?>
<ul id="menu-list">
<div class="menu-button">
<?php wp_list_pages( $args, 'sort_column=menu_order' ); ?>
<li class="page_item page-item-99">
<a href="<?php $redirect = bloginfo('url'); wp_logout_url( $redirect ); ?>">
Logout
</a>
</li>
</div>
</ul>
<div class="divider"></div>
<p id="board">Viewing content for: <br />Aneurin Bevan Health Board</p>
<div style="margin-top:7px!IMPORTANT;" class="divider"></div>
<?php } else {
$args1 = array(
'depth' => 1,
'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0,
'exclude' => '25, 31, 33, 43, 93, 96, 99, 138',
'include' => '',
'title_li' => __(''),
'echo' => 1,
'authors' => '',
'sort_column' => 'menu_order, post_title',
'link_before' => '',
'link_after' => '',
'walker' => '' );
?>
<ul id="menu-list">
<div class="menu-button">
<?php wp_list_pages( $args1, 'sort_column=menu_order' ); ?>
</div>
</ul>
<?php } ?>
I'm using the following for a user to logout of the CMS:
<a href="<?php $redirect = bloginfo('url'); wp_logout_url( $redirect ); ?>">Logout</a>
Even though the page reloads after clicking the logout link, the menu doesn't seem to change. Does anyone know what's going wrong?
UPDATE
I've tried using <?php $redirect = bloginfo('url'); wp_logout( $redirect, $echo ); ?> which I thought was working perfectly until a colleague shouted across the room that they had been logged out too! Turns out it's logging everyone out instead of just logging out the user that clicked the logout link!
<div>inside aulthat is invalid HTML. – janw Sep 26 '12 at 8:34