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
Wordpress user.php在密码检查时返回错误500_Php_Wordpress - Fatal编程技术网

Wordpress user.php在密码检查时返回错误500

Wordpress user.php在密码检查时返回错误500,php,wordpress,Php,Wordpress,尝试创建一个连接器,检查用户名和密码是否匹配,然后回显用户名和密码是否有效: <?php //$username = $_POST["user"]; //$password = $_POST["password"]; $username = 'existingusername'; //debug test $password = 'password'; // debug test include_once(dirname(__FILE__) .

尝试创建一个连接器,检查用户名和密码是否匹配,然后回显用户名和密码是否有效:

<?php

    //$username = $_POST["user"];
    //$password = $_POST["password"];
    $username = 'existingusername'; //debug test
    $password = 'password'; // debug test

    include_once(dirname(__FILE__) . "/wp-includes/user.php");

    if (function_exists('wp_authenticate_username_password')) { 

        $auth = wp_authenticate_username_password(NULL, $username, $password);

        if (is_wp_error($auth)) 
        {
            echo 'Fail';
        } else {
            echo 'Success';
        }

    }else{

        echo 'Could not find wp_authenticate_username_password function<br>';
        echo dirname(__FILE__) . "/wp-includes/user.php";

    }

?>

我正在使用user.php文件中的函数,它是:

/**
 * Authenticate the user using the username and password.
 *
 * @since 2.8.0
 *
 * @param WP_User|WP_Error|null $user     WP_User or WP_Error object from a previous callback. Default null.
 * @param string                $username Username for authentication.
 * @param string                $password Password for authentication.
 * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
 */
function wp_authenticate_username_password($user, $username, $password) {
    if ( is_a( $user, 'WP_User' ) ) {
        return $user;
    }

    if ( empty($username) || empty($password) ) {
        if ( is_wp_error( $user ) )
            return $user;

        $error = new WP_Error();

        if ( empty($username) )
            $error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));

        if ( empty($password) )
            $error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));

        return $error;
    }

    $user = get_user_by('login', $username);

    if ( !$user )
        return new WP_Error( 'invalid_username', sprintf( __( '<strong>ERROR</strong>: Invalid username. <a href="%s">Lost your password</a>?' ), wp_lostpassword_url() ) );

    /**
     * Filter whether the given user can be authenticated with the provided $password.
     *
     * @since 2.5.0
     *
     * @param WP_User|WP_Error $user     WP_User or WP_Error object if a previous
     *                                   callback failed authentication.
     * @param string           $password Password to check against the user.
     */
    $user = apply_filters( 'wp_authenticate_user', $user, $password );
    if ( is_wp_error($user) )
        return $user;

    if ( !wp_check_password($password, $user->user_pass, $user->ID) )
        return new WP_Error( 'incorrect_password', sprintf( __( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s">Lost your password</a>?' ),
        $username, wp_lostpassword_url() ) );

    return $user;
}
/**
*使用用户名和密码对用户进行身份验证。
*
*@自2.8.0以来
*
*@param WP_User | WP_Error | null$User WP_User或上一次回调中的WP_Error对象。默认为空。
*@param string$username用于身份验证。
*@param string$用于身份验证的密码。
*@return WP_User | WP_Error WP_User成功,WP_Error失败。
*/
函数wp\u authenticate\u username\u password($user、$username、$password){
如果(是($user,'WP\u user')){
返回$user;
}
if(空($username)| |空($password)){
如果(是错误($user))
返回$user;
$error=新的WP_错误();
if(空($username))
$error->add('empty_username','uuu('error:username字段为空');
if(空($password))
$error->add('empty_password','u_('error:password字段为空');
返回$error;
}
$user=get_user_by('login',$username);
如果(!$user)
返回新的WP_错误('invalid_username',sprintf('invalid_username'),WP_lostpassword_url());
/**
*筛选是否可以使用提供的$password对给定用户进行身份验证。
*
*@自2.5.0以来
*
*@param WP_User | WP_Error$User WP_User或WP_Error对象,如果以前的
*回调身份验证失败。
*@param string$密码用于检查用户的密码。
*/
$user=apply_过滤器('wp_authenticate_user',$user,$password);
如果(是错误($user))
返回$user;
如果(!wp\u check\u password($password,$user->user\u pass,$user->ID))
返回新的WP_错误('Error_password',sprintf('Error:您为用户名%1$s输入的密码不正确。?'),
$username,wp_lostpassword_url());
返回$user;
}
它给了我一个错误500页。调用此函数的其他脚本(它是一个外部服务器,用于侦听回声是否成功)

我知道另一个脚本的工作原理就好像我只做了一个能够响应“Success”的php页面;它允许我登录


谢谢

在PHP错误日志中查找实际错误,否则无法调试。在PHP错误日志中查找实际错误,否则无法调试。