WordPress at a glance

wp_create_user() WP 1.0

A simpler way of inserting a user into the database.

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: wp_insert_user() More complete way to create a new user
Is the basis for: register_new_user()
Works based on: wp_insert_user()

No Hooks.


Int/WP_Error. The newly created user's ID or a WP_Error object if the user could not be created.


wp_create_user( $username, $password, $email );
$username(string) (required)
The user's username.
$password(string) (required)
The user's password.
The user's email.
Default: ''

Code of wp_create_user: wp-includes/user.php VER 5.0.1

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);

Related Functions

From tag: Users (_user)

More from category: User insertion/removal

No comments
    Hello, !     Log In . Register