Reputation: 637
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);
where $userdata is an array containing elements as
$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.
Upvotes: 1
Views: 2883
Reputation: 6511
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
}
Upvotes: 1