WordPress函数文档add_new_user_to_blog()
添加一个新用户到博客(多站点) 描述 Add a newly created user to the appr…
添加一个新用户到博客(多站点)
描述
Add a newly created user to the appropriate blog.
用法
<?php add_new_user_to_blog( $user_id, $email, $meta ) ?>
参数
$user_id
(integer) (必填) The new user ID
默认值: None
(string) (必填) New user’s email
默认值: None
$meta
(array) (必填) Sign-up meta for a user. The ‘add_to_blog’ and ‘new_role’ fields are used.
默认值: None
示例
1
2
3
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
|
注意
- 使用到 remove_user_from_blog() to remove the user from the main blog.
- 使用到 add_user_to_blog() to add the user to the blog whose ID is given in $meta[‘add_to_blog’].
- 使用到 update_user_meta() to update the ‘primary_blog’ meta key.
历史
添加于 版本: MU (3.0.0)
源文件
add_new_user_to_blog() 函数的代码位于 wp-includes/ms-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Add 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.
*
* @since MU
* @see add_user_to_blog()
*
* @param int $user_id
* @param mixed $password Ignored.
* @param array $meta
*/
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_current_site()->blog_id); // remove user from main blog.
add_user_to_blog( $blog_id, $user_id, $role );
update_user_meta( $user_id, ‘primary_blog’, $blog_id );
}
}
|
相关
Blog User Function(函数)s: add_user_to_blog(), add_new_user_to_blog(), remove_user_from_blog(), is_user_member_of_blog()
wp_update_user, wp_create_user
- 原文:http://codex.wordpress.org/Function_Reference/add_new_user_to_blog
类别:WordPress函数文档、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!