[wp-trac] [WordPress Trac] #14602: Create user_can, refactor current_user_can, author_can, current_user_can_for_blog

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 12 18:32:23 UTC 2010


#14602: Create user_can, refactor current_user_can, author_can,
current_user_can_for_blog
---------------------------+------------------------------------------------
 Reporter:  simonwheatley  |       Owner:                         
     Type:  enhancement    |      Status:  new                    
 Priority:  normal         |   Milestone:  Awaiting Review        
Component:  Users          |     Version:  3.0.1                  
 Severity:  normal         |    Keywords:  has-patch needs-testing
---------------------------+------------------------------------------------

Comment(by simonwheatley):

 Looking at the current patch I wonder whether the {{{is_int}}} check in
 the first line of the new {{{user_can}}} function ought to be more like
 this:

 {{{
 function user_can( $user, $capability ) {
         if ( ! is_object( $user ) )
                 $user = new WP_User( (int) $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 );
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14602#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list