Function: wp_create_user

wp_create_user( string $username, string $password, string $email )

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.

Parameters

Name Type(s) Default Value Description
$username string

The user's username.

$password string

The user's password.

$email string ''

Optional. The user's email. Default empty.

Returns

integer | WP_Error

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

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.