Introduce user_can(). Props simonwheatley. fixes #14602
git-svn-id: http://svn.automattic.com/wordpress/trunk@16209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
98c65bd2f7
commit
9a9d29019d
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue