WordPress – Enable Privacy Policy Access for Editors
By default WordPress hides the Privacy Policy page from all user roles except Administrators. The function below opens permissions up slightly allowing Editors to see and edit that page in the WordPress backend.
To enable it just copy the code below into your themes functions.php file.
add_action('map_meta_cap', 'custom_manage_privacy_options', 1, 4);
function custom_manage_privacy_options($caps, $cap, $user_id, $args) {
if ( !is_user_logged_in() ) return $caps;
$target_roles = array('editor', 'administrator');
$user_meta = get_userdata($user_id);
$user_roles = ( array ) $user_meta->roles;
if ( array_intersect($target_roles, $user_roles) ) {
if ('manage_privacy_options' === $cap) {
$manage_name = is_multisite() ? 'manage_network' : 'manage_options';
$caps = array_diff($caps, [ $manage_name ]);
}
}
return $caps;
}

Leave a Reply
Want to join the discussion?Feel free to contribute!