正如标题所示,我正在为我的网站用户构建一个定制的前端登录页面。我正在使用wp\\u signon在验证用户的凭据后登录,但出现以下错误:
Warning: Cannot modify header information - headers already sent by (output started at C:\\xampp\\htdocs\\wordpress\\wp-content\\themes\\twentyeleven\\header.php:13) in C:\\xampp\\htdocs\\wordpress\\wp-includes\\pluggable.php on line 737
twentyeleven\\标题。php:13显示了这一点(包括上面和下面的行):
<!--[if IE 6]>
<html id="ie6" <?php language_attribute(); ?>>
<![endif]-->
我读过一两篇文章说,wp\\u登录必须在创建任何页面内容之前发生,因为它会改变标题,但我想我不太确定当时该如何使用它。wp\\U signon应该去哪里?以下是我的代码结构:
//Retrieve submitted $_POST values.
//Check if this is the first time the form has been displayed (there is a hidden input at the end of the form that changes a boolean to false for all future submits)
//If it\'s not the first time, do form validation and create an array with error ID\'s to be displayed in the form. One of these possible errors is wrong username/password combo:
if (!get_userdatabylogin( $submitted[\'email\'] ))
$errors[\'emailIsValid\'] = false;
else
{
$user_data = get_userdatabylogin( $submitted[\'email\'] );
$password_hashed = $user_data->user_pass;
if (wp_check_password($submitted[\'password\'], $password_hashed, $user_data->ID))
{
$credentials = array();
$credentials[\'user_login\'] = $submitted[\'email\'];
$credentials[\'user_password\'] = $submitted[\'password\'];
if (empty($submitted[\'rememberme\']))
$credentials[\'remember\'] = false;
else
$credentials[\'remember\'] = true;
wp_signon($credentials, true);
}
else
errors[\'passwordMatchesEmail\'] = false;
}
//Check to see if the errors array has any flags, if so flag a variable to say errors exist
//Form code: form submits to itself
//Check error flags and display error message accordingly
//Display body of form
除此之外,一切都很好
wp_signon
线输入正确的凭据会产生我上面提到的错误。