[英]Add User in wordpress without username
I have made a registration form which have only two fields email and password .Now i want to add user to Wordpress database but wp_create_user()
require username too.Then i tried using another function as $status=wp_insert_user($userdata);
我已经创建了一个只有两个字段的电子邮件和密码注册表格。现在我想将用户添加到Wordpress数据库,但是wp_create_user()
需要用户名。然后我尝试使用另一个功能,如$status=wp_insert_user($userdata);
where $userdata is an array containing elements as 其中$ userdata是一个包含以下元素的数组:
$userdata = array(
'user_pass' => $pswrd,
'user_email'=> $email
);
but user is not added in database. 但是没有将用户添加到数据库中。 Is their any other function through which i can add user with above two fields only. 是他们的任何其他功能,我只能通过它们通过以上两个字段添加用户。
If you don't want to ask the user for a specific login name, you could use their e-mail: 如果您不想询问用户特定的登录名,则可以使用他们的电子邮件:
if ( !username_exists( $email ) {
$user_id = wp_create_user( $email, $pswrd, $email );
if ( !is_wp_error( $user_id ) ) {
// created succesfully
}
} else {
// Username already exists
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.