WordPress:Function Reference/wp create user

来自站长百科
Xxf3325讨论 | 贡献2008年7月19日 (六) 11:52的版本 (新页面: == Description == The wp_create_user function allows you to insert a new user into the WordPress database by parsing 3 (three) parameters ...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Description

The wp_create_user function allows you to insert a new user into the WordPress database by parsing 3 (three) parameters through to the function itself. It uses the $wpdb class to escape the variable values, preparing it for insertion into the database. Then the PHP compact() function is used to create an array with these values.

Usage

%%% <?php wp_create_user($username, $password, $email ); ?> %%%

Example

As used in wp-admin/upgrade-functions.php:

$user_id = username_exists($user_name);
if ( !$user_id ) {
	$random_password = substr(md5(uniqid(microtime())), 0, 6);
	$user_id = wp_create_user($user_name, $random_password, $user_email);
} else {
	$random_password = __('User already exists.  Password inherited.');
}

Parameters

Returns

This function returns the user ID of the created user.