我收到以下代码的重定向错误。只是当表单提交并检查了某个用户名时,它应该重定向到某个页面。
<div>
<?php
global $user;
if (isset($user->name)) {
echo "You don't have permission to access the administrator with the current logged in user (".$user->name."). ". "<a href='./user/logout'>Log Out as (" . $user->name . ")</a>"."<br /><br />";
}
?>
Please refer to the credentials sent to you.</div>
<?php
if ($user->name == "a-particular-user") {
header( 'Location: http://url.to.direct' ) ;
}
?>
在重定向页面上,以下代码退出
global $user;
$adminuser = false;
if (in_array('administrator', array_values($user->roles)))
$adminuser = true;
if ( !($adminuser) && ($user->name != "rockstar")) {
echo "<br /><br />";
echo "<h2> You need to be an Administrator to see this page.</h2>";
exit();
}