Skip to content

Instantly share code, notes, and snippets.

@ouun
Created January 5, 2021 14:18
Show Gist options
  • Save ouun/1dfd204081558c4f375c3476fdb6dc38 to your computer and use it in GitHub Desktop.
Save ouun/1dfd204081558c4f375c3476fdb6dc38 to your computer and use it in GitHub Desktop.
<?php
/**
* Customize caps to edit Privacy Page
*/
add_action('map_meta_cap', function ($caps, $cap, $user_id, $args) {
$user_meta = get_userdata($user_id);
if ($user_meta) {
if (array_intersect(['shop_manager', 'administrator'], $user_meta->roles)) {
if ('manage_privacy_options' === $cap) {
$manage_name = is_multisite() ? 'manage_network' : 'manage_options';
$caps = array_diff($caps, [$manage_name]);
}
}
}
return $caps;
}, 1, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment