user_can( int|WP_User $user, string $capability )
Whether a particular user has a specific capability.
Description Description
Parameters Parameters
- $user
-
(int|WP_User) (Required) User ID or object.
- $capability
-
(string) (Required) Capability name.
Return Return
(bool) Whether the user has the given capability.
Source Source
File: wp-includes/capabilities.php
function user_can( $user, $capability ) {
if ( ! is_object( $user ) ) {
$user = get_userdata( $user );
}
if ( ! $user || ! $user->exists() ) {
return false;
}
$args = array_slice( func_get_args(), 2 );
$args = array_merge( array( $capability ), $args );
return call_user_func_array( array( $user, 'has_cap' ), $args );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |