Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wp_authenticate()返回wordpress中有效用户名和密码的错误?_Php_Wordpress - Fatal编程技术网

Php wp_authenticate()返回wordpress中有效用户名和密码的错误?

Php wp_authenticate()返回wordpress中有效用户名和密码的错误?,php,wordpress,Php,Wordpress,我已经创建了一个自定义lo-gin表单。我正在使用wp_authenticate()进行身份验证,但它返回了有效用户名和密码的错误。请指出我可能犯的错误。 谢谢 下面是代码 $user_name = sanitize_user($_POST['log']); $user_pass = $_POST['pwd']; $user = wp_authenticate_user($user_name, $user_pass); 请尝试以下方法: $creds = array(); $creds['us

我已经创建了一个自定义lo-gin表单。我正在使用wp_authenticate()进行身份验证,但它返回了有效用户名和密码的错误。请指出我可能犯的错误。 谢谢 下面是代码

$user_name = sanitize_user($_POST['log']);
$user_pass = $_POST['pwd'];
$user = wp_authenticate_user($user_name, $user_pass);
请尝试以下方法:

$creds = array();
$creds['user_login'] = $user_name;
$creds['user_password'] = $user_pass;
$creds['remember'] = true; //Or false

$user = wp_signon( $creds, false );
if ( is_wp_error($user) ){
   //There is an error logging in
   echo $user->get_error_message();
}else{
   //Login successfull
}