Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#16451 closed defect (bug) (invalid)

WP_Roles and capabilities

Reported by: im_natascha's profile IM_natascha Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.4
Component: Role/Capability Keywords:
Focuses: Cc:

Description

I began to complain about this in the support forum: http://wordpress.org/support/topic/bug-report-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.

Change History (4)

#1 @scribu
13 years ago

  • Component changed from Users to Role/Capability

#2 @scribu
13 years ago

It would be helpful if you posted the code you have written, as a reference.

#3 @c3mdigital
11 years ago

  • Keywords WP_Role capabilities removed
  • Resolution set to invalid
  • Status changed from new to closed

I don't see this as a bug. If you would like to reopen please provide code as a reference.

#4 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.