role_has_cap
Filter HookDescription
Filters which capabilities a role has.Hook Information
File Location |
wp-includes/class-wp-role.php
View on GitHub
|
Hook Type | Filter |
Line Number | 95 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool[]
|
$capabilities
|
Array of key/value pairs where keys represent a capability name and boolean values represent whether the role has that capability. |
string
|
$cap
|
Capability name. |
string
|
$name
|
Role name. |
Usage Examples
Basic Usage
<?php
// Hook into role_has_cap
add_filter('role_has_cap', 'my_custom_filter', 10, 3);
function my_custom_filter($capabilities, $cap, $name) {
// Your custom filtering logic here
return $capabilities;
}
Source Code Context
wp-includes/class-wp-role.php:95
- How this hook is used in WordPress core
<?php
90 * @param bool[] $capabilities Array of key/value pairs where keys represent a capability name and boolean values
91 * represent whether the role has that capability.
92 * @param string $cap Capability name.
93 * @param string $name Role name.
94 */
95 $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );
96
97 if ( ! empty( $capabilities[ $cap ] ) ) {
98 return $capabilities[ $cap ];
99 } else {
100 return false;
PHP Documentation
<?php
/**
* Filters which capabilities a role has.
*
* @since 2.0.0
*
* @param bool[] $capabilities Array of key/value pairs where keys represent a capability name and boolean values
* represent whether the role has that capability.
* @param string $cap Capability name.
* @param string $name Role name.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/class-wp-role.php
Related Hooks
Related hooks will be displayed here in future updates.