当我运行wp_signon()我有几个警告与此类似: “警告:不能更改头信息 - 头已经发出(输出开始/网络/ htdocs中/ WWW .example.com/home/wp-includes/class.wp-styles.php:237)in /web/htdocs/www.mysite.com/home/wp-includes/pluggable.php on line 892“ It无论如何做登录,如果我改变页面,然后不给我没有问题,但我不明白这些错误。 我附上了登录代码。 非常感谢您的帮助!错误WordPress的wp_signon()函数
的header.php:
<div id="loginbar">
<?php $current_user = wp_get_current_user();
if(isset($_POST["submit"])){
custom_login();
}?>
<?php if(!is_user_logged_in()): ?>
<form name="frontlog" method="post">
<input id= "log" type="text" name="log" placeholder="Username">
<input id= "pwd" type="password" name="pwd" placeholder="Password">
<input type= "submit" name="submit" class="linkbuttonleft" id="loginbutton">
</form>
<a class="linkbuttonright" title="Registrati" href="http://www.example.com/registrazione/">
<img id="chiave" src="http://www.example.com/wp-content/themes/BiscuitsTheme/immagini/chiave.png" onmousedown="return false"></a>
<?php else: ?>
<p> <?php echo 'Benvenuto ' . $current_user->user_login;?> </p>
<a class="linkbuttonleft" title="Logout" href="<?php echo wp_logout_url(home_url()); ?>"></a>
<img id="lucchetto" src="http://www.example.com/wp-content/themes/BiscuitsTheme/immagini/lucchetto.png" onmousedown="return false"></a>
<a class="linkbuttonright" title="Profilo" href="http://www.example.com/profilo/">
<img id="profilo" src="http://www.example.com/wp-content/themes/BiscuitsTheme/immagini/profilo.png" onmousedown="return false"></a>
<?php endif; ?>
</div>
的functions.php:
function custom_login() {
$creds = array();
$creds = array(
'user_login' => $_POST["log"],
'user_password' => $_POST["pwd"],
'remember' => true
);
$user = wp_signon($creds, false);
if (is_wp_error($user)) {
echo $user->get_error_message();
}
else {
wp_set_current_user($user->ID, $user->name);
wp_set_auth_cookie($user->ID, true, false);
}
};add_action('after_setup_theme', 'custom_login');
这意味着服务器已经发送了头信息,以便要么你有不同的页眉或回声功能的地方,然后试图重定向 - 登录后。在上面的错误信息中检查文件n行号。 – user769889
可能的[如何修复]已经发送的头文件“PHP错误”的副本(http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) –