我想根据用户是否登录CMS显示不同的菜单。
我正在使用此菜单:
<?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 } ?>
我使用以下命令让用户注销CMS:
<a href="<?php $redirect = bloginfo(\'url\'); wp_logout_url( $redirect ); ?>">Logout</a>
即使页面在单击注销链接后重新加载,菜单似乎没有改变。有人知道出了什么问题吗?
<小时>
UPDATE
我试过使用
<?php $redirect = bloginfo(\'url\'); wp_logout( $redirect, $echo ); ?>
我认为它工作得很好,直到一位同事在房间里大声喊道他们也已经注销了!原来它是让所有人都注销,而不是让点击注销链接的用户注销!