wp_create_user

The timeline below displays how wordpress function wp_create_user has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Provides 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.
 *
 * @since 2.0.0
 *
 * @see wp_insert_user() More complete way to create a new user.
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email    Optional. The user's email. Default empty.
 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
 *                      be created.
 */
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);
}

WordPress Version: 5.5

/**
 * 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.
 *
 * @since 2.0.0
 *
 * @see wp_insert_user() More complete way to create a new user.
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email    Optional. The user's email. Default empty.
 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
 *                      be created.
 */
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);
}

WordPress Version: 4.6

/**
 * 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.
 *
 * @since 2.0.0
 * @see wp_insert_user() More complete way to create a new user
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email    Optional. The user's email. Default empty.
 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
 *                      be created.
 */
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);
}

WordPress Version: 4.4

/**
 * 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 {@see wp_insert_user()} to specify more information.
 *
 * @since 2.0.0
 * @see wp_insert_user() More complete way to create a new user
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email    Optional. The user's email. Default empty.
 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
 *                      be created.
 */
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);
}

WordPress Version: 4.3

/**
 * 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 {@see wp_insert_user()} to specify more information.
 *
 * @since 2.0.0
 * @see wp_insert_user() More complete way to create a new user
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email    Optional. The user's email. Default empty.
 * @return int|WP_Error The new user's ID.
 */
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);
}

WordPress Version: 4.2

/**
 * 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 {@see wp_insert_user()} to specify more information.
 *
 * @since 2.0.0
 * @see wp_insert_user() More complete way to create a new user
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email    Optional. The user's email. Default empty.
 * @return int The new user's ID.
 */
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);
}

WordPress Version: 4.1

/**
 * A simpler way of inserting an user into the database.
 *
 * Creates a new user with just the username, password, and email. For more
 * complex user creation use {@see wp_insert_user()} to specify more information.
 *
 * @since 2.0.0
 * @see wp_insert_user() More complete way to create a new user
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email    Optional. The user's email. Default empty.
 * @return int The new user's ID.
 */
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);
}

WordPress Version: 3.7

/**
 * A simpler way of inserting an 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.
 *
 * @since 2.0.0
 * @see wp_insert_user() More complete way to create a new user
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email The user's email (optional).
 * @return int The new user's ID.
 */
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);
}