WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 5 years ago

Last modified 5 years ago

#19747 closed defect (bug) (duplicate)

Roles add_cap should call update_user_level_from_caps()

Reported by: lgladdy Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: Role/Capability Keywords:
Focuses: Cc:
PR Number:

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)

#1 @scottconnerly
7 years ago

  • Cc scott@… added

#2 @BandonRandon
7 years ago

  • Cc BandonRandon added

#3 @nacin
6 years ago

  • Keywords reporter-feedback needs-unit-tests added

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.

#4 @lgladdy
6 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!

This ticket was mentioned in Slack in #core by lgladdy. View the logs.


5 years ago

#7 @lgladdy
5 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #28374.

Reading the patch for #28374, that resolves this ticket :)

Last edited 5 years ago by lgladdy (previous) (diff)

#8 @SergeyBiryukov
5 years ago

  • Keywords reporter-feedback needs-unit-tests removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.