add_new_user_to_blog() - WordPress 函数参考中文文档

返回介绍

add_new_user_to_blog()

发布于 2017-09-10 字数1680 浏览 1026 评论 0

add_new_user_to_blog( int $user_id,  mixed $password,  array $meta )

Adds a newly created user to the appropriate blog


描述

To add a user in general, use add_user_to_blog(). This function is specifically hooked into the ‘wpmu_activate_user’ action.


参数

$user_id

(int)
(Required)

$password

(mixed)
(Required)
Ignored.

$meta

(array)
(Required)


源代码

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.
		add_user_to_blog( $blog_id, $user_id, $role );
		update_user_meta( $user_id, 'primary_blog', $blog_id );
	}
}

更新日志

Version 描述
MU Introduced.

相关函数

Uses

  • wp-includes/ms-blogs.php:
    get_network()
  • wp-includes/user.php:
    update_user_meta()
  • wp-includes/ms-functions.php:
    remove_user_from_blog()
  • wp-includes/ms-functions.php:
    add_user_to_blog()

User Contributed Notes

上一篇:add_network_option()

下一篇:add_object_page()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!