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

目录

描述

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

add_user_to_blog() 描述

用法

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

add_user_to_blog() 用法

参数

$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

add_user_to_blog() 参数

示例

add_user_to_blog() 示例

注意

  • 使用到 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 restore the current blog before returning as well.

add_user_to_blog() 注意

源文件

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

add_user_to_blog() 源文件

相关