[wp-trac] [WordPress Trac] #5541: Refactor and simplify WP_Roles

WordPress Trac wp-trac at lists.automattic.com
Fri Dec 28 07:43:37 GMT 2007

#5541: Refactor and simplify WP_Roles
 Reporter:  tellyworth   |       Owner:  anonymous
     Type:  enhancement  |      Status:  new      
 Priority:  normal       |   Milestone:  2.5      
Component:  General      |     Version:           
 Severity:  normal       |    Keywords:  has-patch
 This patch simplifies the way WP_Roles is implemented.  Roles are no
 longer stored in the options table.  Instead they are populated at runtime
 by an action.  An action handler in capabilities.php populates the
 standard roles with current default capabilities.  Plugins can hook the
 same init_roles action to create their own roles.

 I also included some related fixes and improvements:

 * Capabilities were duplicated in two places previously (in
 WP_Roles::roles and again in WP_Role::capabilities).  This created a bug
 where calling $wp_roles->add_cap() could cause the two to get out of sync.
 They're kept in a single place now.

 * There's a new "{$role}_has_cap" filter that's considerably easier to use
 than the old role_has_cap filter (it has only one argument).

 Issues: I deliberately haven't yet provided an upgrade path for blogs that
 have custom roles stored in the options table.  That might be necessary
 but I'm not sure how common or vital it is.

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

More information about the wp-trac mailing list