函数原型
wp_create_user( string $username, string $password, string $email = ” ): int|WP_Error
函数描述
Provides a simpler way of inserting a user into the database.
是否弃用
未弃用
函数参数
-
$username
string
Required - The user’s username.
-
$password
string
Required - The user’s password.
-
$email
string
Optional - The user’s email.
Default:
''
函数返回值
int|WP_Error The newly created user’s ID or a WP_Error object if the user could not be created.
函数位置
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 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |

