Provides a simpler way of inserting a user into the database.
Description
Creates a new user with just the username, password, and email. For more complex user creation use wp_insert_user() to specify more information.
See also
- wp_insert_user(): More complete way to create a new user.
Parameters
$username
stringrequired- The user’s username.
$password
stringrequired- The user’s password.
$email
stringoptional- The user’s email.
Default:
''
Source
function wp_create_user( $username, $password, $email = '' ) {
$user_login = wp_slash( $username );
$user_email = wp_slash( $email );
$user_pass = $password;
$userdata = compact( 'user_login', 'user_email', 'user_pass' );
return wp_insert_user( $userdata );
}
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
Basic Example
As used in wp-admin/upgrade-functions.php:
Just a note:
As mentioned in the wp_insert_user() function arguments, the password expected here is plain text password.
user_pass (string): The plain-text user password.