[wp-trac] [WordPress Trac] #16451: WP_Roles and capabilities

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 3 19:06:29 UTC 2011

#16451: WP_Roles and capabilities
 Reporter:  IM_natascha   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Users         |    Version:  3.0.4
 Severity:  normal        |   Keywords:  WP_Role, capabilities
 I began to complain about this in the support forum:
 wp_roles?replies=3#post-1922100 . You can read the longer version there.

 The WP_Roles-Class lacks some consistency (immo). I am not aware of the
 reasons why WP_Roles multiple class-varibles containing the roles and
 capabilities, but in this case your logic is producing some errors:

 I wrote my Plugins as classes. While Wordpress loads them, I add the roles
 and capabilities this plugin needs. It would have been far more
 complicated to do this only while activating.

 Creating a WP_User-Object, it will set it's "all_caps" from
 $wp_roles->get_caps($role) which is looking into the
 $wp_roles->role_objects[$role]. There it will only find those capability
 of the $role, which were assigned while creating the role [
 $wp_roles->add_role($identifier, $readable, $caps) ] but NONE of the caps
 added by [ $wp_roles->add_cap($role, $cap, $grant) ] because this function
 applies the capability to $wp_roles->roles but not to
 $wp_roles->role_objects, where WP_User will look into with the method [
 $wp_roles->get_caps($role) ]

 I use this as an example cause I faced this problem the last three days.
 The fact is, if you need those multiple variables in WP_Roles, please,
 keep them all up-to-date. Do not force the user to set all capabilities in
 the activation and do not rely on the thought that roles and capabilities
 will be set correctly if read from the database.

 As the changes are minor and the effect major, it would be great to change
 it soon.

Ticket URL: <http://core.trac.wordpress.org/ticket/16451>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list