[wp-trac] [WordPress Trac] #42332: delete_site permission is not working as it should
WordPress Trac
noreply at wordpress.org
Wed Oct 25 14:04:42 UTC 2017
#42332: delete_site permission is not working as it should
-------------------------------+------------------------------
Reporter: Shebo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Role/Capability | Version: 4.2
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses: multisite
-------------------------------+------------------------------
Changes (by johnbillion):
* keywords: => reporter-feedback
* version: trunk => 4.2
Comment:
Thanks for the report, @Shebo.
The `delete_site` capability is a ''meta'' capability, which means the
capability is only granted to a user or a role at runtime according to
logic (in this case, mapping it to the `manage_options` primitive
capability). Granting a meta capability directly to a user or a role won't
work.
In order to actually grant a user the `delete_site` capability, you'll
also need to implement a filter such as the following ''in addition'' to
granting them the `delete_site` capability via their user or their role:
{{{#!php
add_filter( 'map_meta_cap', function( array $required_caps, $cap,
$user_id, array $args ) {
if ( 'delete_site' === $cap ) {
$required_caps = array(
'delete_site',
);
}
return $required_caps;
}, 10, 4 );
}}}
Can you let us know if this works as expected?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42332#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list