Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy
Created July 27, 2025 16:00
Show Gist options
  • Select an option

  • Save 2ndkauboy/741683cf08072b9b37a395a078862e49 to your computer and use it in GitHub Desktop.

Select an option

Save 2ndkauboy/741683cf08072b9b37a395a078862e49 to your computer and use it in GitHub Desktop.
Allow editors to edit the content of the privacy policy page
<?php
/**
* Allow Privacy Policy Page Edits
*
* @package AllowPrivacyPolicyPageEdits
* @author Bernhard Kau
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Allow Privacy Policy Page Edits
* Plugin URI: https://gist.github.com/2ndkauboy/741683cf08072b9b37a395a078862e49
* Description: Allow editors to edit the content of the privacy policy page.
* Version: 1.0.0
* Requires at least: 4.9
* Author: Bernhard Kau
* Author URI: https://kau-boys.de
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* Adjusts the capabilities required to edit the privacy policy page.
*
* @param string[] $caps Primitive capabilities required of the user.
* @param string $cap Capability being checked.
*
* @return string[] Primitive capabilities required of the user.
*/
function allow_privacy_policy_page_edits( $caps, $cap ) {
if ( $cap !== 'manage_privacy_options' ) {
return $caps;
}
return array_diff( $caps, [ 'manage_options' ] );
}
add_filter( 'map_meta_cap', 'allow_privacy_policy_page_edits', 10, 2 );
@rtpHarry
Copy link

For multisite its manage_network not manage_options.

I needed to do this for shop managers so I also wanted to add the cap to them and settled on this:

add_action( 'admin_init', function () {
    foreach ( [ 'editor', 'shop_manager' ] as $role_name ) {
        $role = get_role( $role_name );
        if ( $role ) {
            $role->add_cap( 'manage_privacy_options' );
        }
    }
} );

add_filter( 'map_meta_cap', function ( array $caps, string $cap ) : array {
    if ( 'manage_privacy_options' !== $cap ) {
        return $caps;
    }

    $admin_cap = is_multisite() ? 'manage_network' : 'manage_options';

    return array_values( array_diff( $caps, [ $admin_cap ] ) );
}, 10, 2 );

If you use this on your site you can remove the add_action after you have added it, then visited the admin panel once. You need to keep the map_meta_cap for every request though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment