apply_filters( 'user_has_cap', bool[] $allcaps, string[] $caps, array $args, WP_User $user )
- Since
- 2.0.0, 3.7.0
Dynamically filter a user's capabilities.
Compatibility
- WordPress
- since 3.7.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$allcapsbool[]- Array of key/value pairs where keys represent a capability name and boolean values represent whether the user has that capability.
$capsstring[]- Required primitive capabilities for the requested capability.
$argsarray- { Arguments that accompany the requested capability check.
@type string $0 Requested capability.
@type int $1 Concerned user ID.
@type mixed ...$2 Optional second and further parameters, typically object ID.
}$0stringRequested capability.$1intConcerned user ID....$2mixedOptional second and further parameters, typically object ID.
$userWP_User- The user object.
Where this hook fires · 1
wp-includes/class-wp-user.php:824WP_User::has_cap()
Source code
* @type string $0 Requested capability. * @type int $1 Concerned user ID. * @type mixed ...$2 Optional second and further parameters, typically object ID. * } * @param WP_User $user The user object. */ $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); // Everyone is allowed to exist. $capabilities['exist'] = true; // Nobody is allowed to do things they are not allowed to do. unset( $capabilities['do_not_allow'] );Changelog
Introduced in 2.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
3.7.0
Added the
$user parameter.from the docblock2.0.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.