函数原型
add_new_user_to_blog( int $user_id, string $password, array $meta )
函数描述
Adds a newly created user to the appropriate blog
是否弃用
未弃用
函数参数
-
$user_id
int
Required - User ID.
-
$password
string
Required - User password. Ignored.
-
$meta
array
Required - Signup meta data.
函数返回值
无
函数位置
File: wp-includes/ms-functions.php.
函数源码
function add_new_user_to_blog( $user_id, $password, $meta ) {
if ( ! empty( $meta['add_to_blog'] ) ) {
$blog_id = $meta['add_to_blog'];
$role = $meta['new_role'];
remove_user_from_blog( $user_id, get_network()->site_id ); // Remove user from main blog.
$result = add_user_to_blog( $blog_id, $user_id, $role );
if ( ! is_wp_error( $result ) ) {
update_user_meta( $user_id, 'primary_blog', $blog_id );
}
}
}
源码链接
变更日志
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |

