#19747 closed defect (bug) (duplicate)
Roles add_cap should call update_user_level_from_caps()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3.1 |
Component: | Role/Capability | Keywords: | |
Focuses: | Cc: |
Description
Hey guys,
I've created a new user role, which didn't appear in the Author drop down list due to #16841. The workaround is to add a level_1 capability to that user, but because wordpress doesn't call update_user_level_from_caps() function when you add_cap, that isn't actually applied to existing users on the role, and you have to move them to a different role and back again if you want to apply the changed user role.
I'd suggest adding a call to update_user_level_from_caps() to add_cap (and remove_cap) to fix this in wp-includes/capabilities.php
Change History (8)
#4
@
7 years ago
Hey Nacin,
It's been a little while since i opened this, so i'm trying to recall our use case, I think it was basically that when you add a deprecated level_x capability to a role, any users who already have that role aren't updated with that capability, because update_user_level_from_caps() isn't called as part of the add_cap.
Looking back, this probably isn't too much of an issue depending on the state of #16841 - I've not needed to do anything with caps in recent releases, but this was back in 3.3 so it may well be something that's changed since then!
Hi lgladdy, sorry you never received a reply here. I'm trying to figure out what's going on. update_user_level_from_caps() gets called when you add a role to a user, which is what you'd be doing when you create a new user role. So maybe the API could do a little more, but I'm not quite sure what the bug is.