wpmu_create_user
函数
wpmu_create_user ( $user_name, $password, $email )
- 参数
-
-
(string)
$user_name
The new user’s login name.- Required: 是
-
(string)
$password
The new user’s password.- Required: 是
-
(string)
$email
The new user’s email address.- Required: 是
-
(string)
- 返回值
-
- (int|false) Returns false on failure, or int $user_id on success
- 定义位置
-
-
wp-includes/ms-functions.php
, line 1307
-
wp-includes/ms-functions.php
- 引入
- –
- 弃用
- –
创建一个用户。
这个函数在用户自我注册以及超级管理员创建新用户时运行。钩住{@see ‘wpmu_new_user’}来处理应该影响所有新用户的事件,但仅在Multisite上(否则使用{@see ‘user_register’})。
function wpmu_create_user( $user_name, $password, $email ) { $user_name = preg_replace( '/s+/', '', sanitize_user( $user_name, true ) ); $user_id = wp_create_user( $user_name, $password, $email ); if ( is_wp_error( $user_id ) ) { return false; } // Newly created users have no roles or caps until they are added to a blog. delete_user_option( $user_id, 'capabilities' ); delete_user_option( $user_id, 'user_level' ); /** * Fires immediately after a new user is created. * * @since MU (3.0.0) * * @param int $user_id User ID. */ do_action( 'wpmu_new_user', $user_id ); return $user_id; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。