[wp-trac] [WordPress Trac] #35551: current_user_can always returns true for Super Admins (Doc update)

WordPress Trac noreply at wordpress.org
Wed Jan 20 22:11:35 UTC 2016


#35551: current_user_can always returns true for Super Admins (Doc update)
-----------------------------+-----------------------------
 Reporter:  finnj            |      Owner:
     Type:  enhancement      |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Role/Capability  |    Version:  4.4.1
 Severity:  normal           |   Keywords:
  Focuses:  docs             |
-----------------------------+-----------------------------
 Codex documentation needs update on current_user_can()

 The documentation does not state, that current_user_can("capability")
 always will return true if user is Super Admin - caused me some grief,
 that I would like to save others :)

 I suggest to add the following to the Notes section:
 current_user_can( $capability ) will aways return true if user is Super
 Admin, unless specifically denied

 Below code is from:
 [https://developer.wordpress.org/reference/classes/wp_user/has_cap/]

 {{{
 // Multisite super admin has all caps by definition, Unless specifically
 denied.
     if ( is_multisite() && is_super_admin( $this->ID ) ) {
         if ( in_array('do_not_allow', $caps) )
             return false;
         return true;
     }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35551>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list