我创建了一个自定义登录表单。我正在使用 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
}