Introduce user_can(). Props simonwheatley. fixes #14602

git-svn-id: https://develop.svn.wordpress.org/trunk@16209 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-11-05 17:04:46 +00:00
parent 20131f4e62
commit b8b7810f52

View File

@ -1079,6 +1079,28 @@ function author_can( $post, $capability ) {
return call_user_func_array( array( &$author, 'has_cap' ), $args );
}
/**
* Whether a particular user has capability or role.
*
* @since 3.1.0
*
* @param int|object $user User ID or object.
* @param string $capability Capability or role name.
* @return bool
*/
function user_can( $user, $capability ) {
if ( ! is_object( $user ) )
$user = new WP_User( $user );
if ( ! $user || ! $user->ID )
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 );
}
/**
* Retrieve role object.
*