role_has_cap
云策文档标注
概述
role_has_cap 是一个 WordPress 过滤器钩子,用于修改角色拥有的能力(capabilities)。它允许开发者在运行时动态调整角色权限。
关键要点
- role_has_cap 过滤器用于过滤角色拥有的能力数组。
- 参数包括 $capabilities(能力数组)、$cap(能力名称)和 $name(角色名称)。
- 在 WP_Role::has_cap() 方法中调用,用于确定角色是否具有特定能力。
- 自 WordPress 2.0.0 版本引入。
代码示例
$capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );
原文内容
Filters which capabilities a role has.
Parameters
$capabilitiesbool[]-
Array of key/value pairs where keys represent a capability name and boolean values represent whether the role has that capability.
$capstring-
Capability name.
$namestring-
Role name.
Source
$capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |