WordPress: Function Reference/wp create user:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == The wp_create_user function allows you to insert a new user into the WordPress database by parsing 3 (three) parameters ...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==


The [[WordPress:Function_Reference/wp_create_user|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 [http://php.net/compact PHP compact() function] is used to create an array with these values.
The [[WordPress:Function_Reference/wp_create_user|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 [http://php.net/compact PHP compact() function] is used to create an array with these values.
[[WordPress:Function_Reference/wp_create_user|wp_create_user]]通过将3个(三个)参数直接解析到函数本身,使你向WordPress数据库添加一名新的用户。函数使用$wpdb class 避免易变的参数值,准备将其插入到数据库中。然后使用[http://php.net/compact PHP compact() 函数]在这些参数值中创建数组。


== Usage ==
== Usage ==
== 用法==
%%% <?php wp_create_user($username, $password, $email ); ?> %%%


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


== Example ==
== Example ==
== 例子 ==
As used in wp-admin/upgrade-functions.php:
As used in wp-admin/upgrade-functions.php:
如用在wp-admin/upgrade-functions.php:
<pre>
$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.');
}
</pre>


<pre>
<pre>
第21行: 第40行:


== Parameters ==
== Parameters ==
== 参数==
{{Parameter|$username|string|The username of the user to be created.}}
{{Parameter|$username|string|The username of the user to be created.}}
{{Parameter|$password|string|The password of the user to be created.}}
{{Parameter|$password|string|The password of the user to be created.}}
{{Parameter|$email|string|The email address of the user to be created.|optional}}
{{Parameter|$email|string|The email address of the user to be created.|optional}}
{{Parameter|$username|string|将要创建的用户的用户名。}}
{{Parameter|$password|string|将要创建的用户的密码。}}
{{Parameter|$email|string|将要创建的用户的电子邮件地址。|可选择的}}


== Returns ==
== Returns ==
== 返回==
This function returns the user ID of the created user.
This function returns the user ID of the created user.
这个函数返回创建的用户的用户ID。

2008年7月19日 (六) 17:25的版本

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.

wp_create_user通过将3个(三个)参数直接解析到函数本身,使你向WordPress数据库添加一名新的用户。函数使用$wpdb class 避免易变的参数值,准备将其插入到数据库中。然后使用PHP compact() 函数在这些参数值中创建数组。

Usage

用法

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

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

Example

例子

As used in wp-admin/upgrade-functions.php: 如用在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.');
}
$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.

这个函数返回创建的用户的用户ID。