Reference › Functions wp_create_user ( string $username , string $password , string $email = '' ): int | WP_Error
Since 2.0.0
Source wp-includes/user.php:2833Description Parameters Return Uses Used by Source History 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.
Parameters
$usernamestring The user's username.
$passwordstring The user's password.
$emailstring optional The user's email. Default empty.Default: '' Return
int | WP_ErrorThe newly created user's ID or a WP_Error object if the user could not be created. Uses · 2 wp_slash() Adds slashes to a string or recursively adds slashes to strings within an array. wp_insert_user() Inserts a user into the database. Source View on Trac ↗ View on GitHub ↗
2833 function wp_create_user ( $username , $password , $email = '' ) { 2834 $user_login = wp_slash ( $username ) ; 2835 $user_email = wp_slash ( $email ) ; 2836 $user_pass = $password ; 2837 2838 $userdata = compact ( 'user_login' , 'user_email' , 'user_pass' ) ; 2839 return wp_insert_user ( $userdata ) ; 2840 } History Introduced in 2.0.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/user.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. Corrections Something wrong on this page? Report it and it gets fixed in the next regeneration.