wp_create_user( string $username, string $password, string $email = '' )
A simpler way of inserting a user into the database.
Contents
Description 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 See also
- wp_insert_user(): More complete way to create a new user
Parameters Parameters
- $username
-
(string) (Required) The user's username.
- $password
-
(string) (Required) The user's password.
-
(string) (Optional) The user's email.
Default value: ''
Return Return
(int|WP_Error) The newly created user's ID or a WP_Error object if the user could not be created.
Source Source
File: wp-includes/user.php
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 ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example
As used in wp-admin/upgrade-functions.php: