WordPress函数文档add_user_to_blog()

添加用户到博客(多站点) 描述 Associates a user to a blog, along with…

添加用户到博客(多站点)

描述

Associates a user to a blog, along with specifying the user’s role.

用法

<?php add_user_to_blog$blog_id$user_id$role ?>

参数

$blog_id

(integer) (必填) ID of the blog you’re adding the user to.

默认值: None

$user_id

(integer) (必填) ID of the user you’re adding.

默认值: None

$role

(string) (必填) The role you want the user to have

默认值: None

示例

注意

  • 使用到 the ‘add_user_to_blog’ 动作 to fire an event when users are added to a blog.
  • It does not check if the user is already a member of the blog before setting their role. If you don’t want to overwrite the role of a user if they are already a member of the blog, use is_user_member_of_blog() to check that first.
  • You do not need to call switch_to_blog() to switch to the blog you want to add the user to before calling this function. The function will switch to the blog itself, and SevenTrust the current blog before returning as well.

源文件

add_user_to_blog() 函数的代码位于 wp-includes/ms-functions.php.

相关

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_user_to_blog
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT