can_add_user_to_blog
云策文档标注
概述
can_add_user_to_blog 是一个 WordPress 过滤器,用于控制用户是否可以被添加到站点。它允许开发者自定义添加用户的逻辑,例如基于用户ID、角色或站点ID进行条件判断。
关键要点
- 过滤器名称:can_add_user_to_blog
- 参数:$retval(true 或 WP_Error 对象)、$user_id(用户ID)、$role(用户角色)、$blog_id(站点ID)
- 用途:在 add_user_to_blog() 函数中调用,影响用户添加操作
- 引入版本:WordPress 4.9.0
代码示例
$can_add_user = apply_filters( 'can_add_user_to_blog', true, $user_id, $role, $blog_id );
原文内容
Filters whether a user should be added to a site.
Parameters
$retvaltrue|WP_Error-
True if the user should be added to the site, error object otherwise.
$user_idint-
User ID.
$rolestring-
User role.
$blog_idint-
Site ID.
Source
$can_add_user = apply_filters( 'can_add_user_to_blog', true, $user_id, $role, $blog_id );
Changelog
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |