Opened 8 years ago
Closed 8 years ago
#39063 closed enhancement (fixed)
Move the logic preventing non-super-admins from deleting themselves into `map_meta_cap()`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Role/Capability | Keywords: | has-patch has-unit-tests commit |
Focuses: | multisite | Cc: |
Description
This is part of the #37616 task. In wp-admin/users.php
there are two ! is_super_admin()
checks to prevent non-super-admins from deleting themselves. This logic should rather be placed in map_meta_cap()
instead of being duplicated in that file. Furthermore, since the mentioned ticket aims at removing is_super_admin()
checks outside of map_meta_cap()
, this will also fulfill that task's goal for these two occurrences.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
39063.diff looks like the right approach and the tests back it up.
It's worth noting that the only place this is enforced at the moment is in
wp-admin/users.php
, not directly inremove_user_from_blog()
. This change effectively moves the enforcement toremove_user_from_blog()
. It's possible, though unlikely, that a plugin allows a site administrator to remove themselves from the site and that this will break the expectation. For this reason, the attached tests fail when applied pre-patch.I'm okay making the change, as it's the right thing to enforce/clarify and can still be filtered. It's also nice to have this solved now as it will be useful as part of improvements to users and multisite in the REST API.