WordPress.org

Make WordPress Core

Changeset 16209


Ignore:
Timestamp:
11/05/10 17:04:46 (6 years ago)
Author:
ryan
Message:

Introduce user_can(). Props simonwheatley. fixes #14602

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/capabilities.php

    r15919 r16209  
    10811081 
    10821082/** 
     1083 * Whether a particular user has capability or role. 
     1084 * 
     1085 * @since 3.1.0 
     1086 * 
     1087 * @param int|object $user User ID or object. 
     1088 * @param string $capability Capability or role name. 
     1089 * @return bool 
     1090 */ 
     1091function user_can( $user, $capability ) { 
     1092    if ( ! is_object( $user ) ) 
     1093        $user = new WP_User( $user ); 
     1094 
     1095    if ( ! $user || ! $user->ID ) 
     1096        return false; 
     1097 
     1098    $args = array_slice( func_get_args(), 2 ); 
     1099    $args = array_merge( array( $capability ), $args ); 
     1100 
     1101    return call_user_func_array( array( &$user, 'has_cap' ), $args ); 
     1102} 
     1103 
     1104/** 
    10831105 * Retrieve role object. 
    10841106 * 
Note: See TracChangeset for help on using the changeset viewer.