Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
Ajax wordpress正在注册,但使用相同的凭据登录不起作用_Ajax_Wordpress_Password Protection - Fatal编程技术网

Ajax wordpress正在注册,但使用相同的凭据登录不起作用

Ajax wordpress正在注册,但使用相同的凭据登录不起作用,ajax,wordpress,password-protection,Ajax,Wordpress,Password Protection,我在wordpress中创建了一个注册表单,并在ajax中进行了注册。 表格是这样的 <form id="user-register-form" method="" action="" novalidate="novalidate"> <div class="full-column-width"> <div class="half-column-width"> <input type

我在wordpress中创建了一个注册表单,并在ajax中进行了注册。 表格是这样的

<form id="user-register-form" method="" action="" novalidate="novalidate">
        <div class="full-column-width">
            <div class="half-column-width">
                <input type="text" name="firstname" placeholder="First Name" id="firstname" required="" aria-required="true">
            </div>
            <div class="half-column-width">
                <input type="text" name="lastname" placeholder="Last Name" id="lastname" required="" aria-required="true">
            </div>
        </div>
        <div class="full-column-width">
            <input type="email" name="email" placeholder="E-mail" id="email" required="" aria-required="true">
        </div>
        <div class="full-column-width">
            <input type="number" name="phone" placeholder="Phone" id="phone" required="" aria-required="true">
        </div>
        <div class="full-column-width">
            <input type="password" name="password" placeholder="Password" id="password" required="" aria-required="true">
        </div>
        <div class="full-column-width">
            <input class="submit" type="submit" name="submit" id="user_get_register" value="Register">
        </div>
    </form>
function user_register() {
    $data = $_POST['data'];
     parse_str($data, $arr);
    $userdata = array (
        'user_login' => $arr['email'],
        'firstname' => $arr['firstname'],
        'lastname' => $arr['lastname'],
        'email' => $arr['email'],
        'phone' => $arr['phone'],
        'password' => $arr['password'],
        );
    //check username exists
    if( username_exists( $arr['email'] ) ) {
        echo 'username exists';
    } 
    else {
        $id = wp_insert_user($userdata);
        if( !is_wp_error( $id )) {
            wp_set_current_user($id);
            wp_set_auth_cookie($id);
            echo 'user created';
        }
    }
    exit;
}
add_action('wp_ajax_nopriv_user_register', 'user_register');
这是做注册用户的详细信息,但当我做同样的详细信息从wordpress管理员登录它不工作。我查过数据库了。价值观在那里。每次我登录到仪表板时,它都会显示出来

ERROR: The password you entered for the username test@name.com is incorrect.

有人能告诉我为什么会有这样的错误吗?如何解决这个问题?

如果用户数据出错,请将密码更改为
user\u pass

$userdata = array (
    'user_login' => $arr['email'],
    'firstname' => $arr['firstname'],
    'lastname' => $arr['lastname'],
    //'email' => $arr['email'], ---- cant store this with this function
    //'phone' => $arr['phone'], --- cant store this with this function
    'user_pass' => $arr['password'],
    );
此外,您正在为wp_insert_user()传递不存在的密钥,您需要将这些密钥保存为usermeta=

update_user_meta( $id, '_telephone', '555-555' ); 

检查输入中的CSS规则。也许他们有文本转换之类的。