#18932 closed defect (bug) (fixed)
WP_User::set_role leaves user object without any caps when role does not change
Reported by: | jammitch | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | minor | Version: | 3.1 |
Component: | Role/Capability | Keywords: | has-patch |
Focuses: | Cc: |
Description
The first thing WP_User::set_role does is clears out the user's existing caps array. Then it checks to see if the passed-in role is the user's current role, and quits the function if so. This is great if the role actually changes. If it does not, this leaves the user with the same role, but without any caps whatsoever for the remainder of the current page.
Core WordPress code may not use the function in this way, but plugins may.
Workaround:
Plugins calling set_role should wrap the call in the same-role check found inside the function.
Fix:
Do the same-role check prior to unsetting the caps.
Attachments (1)
Change History (8)
#1
@
13 years ago
- Summary changed from WP_User::set_role to WP_User::set_role leaves user object without any caps when role does not change
#2
@
13 years ago
- Component changed from General to Role/Capability
- Keywords has-patch added
- Severity changed from normal to minor
Note: See
TracTickets for help on using
tickets.
Confirmed: