DISALLOW_FILE_EDIT constant being ignored
In my wp-config.php
file, I have the line:
define('DISALLOW_FILE_EDIT', true);
I always include this on all sites as standard, and it's always worked exactly as expected. However, I've only just noticed that on one client's site, it has stopped working.
They have the User Role Editor plugin that was set up to define a handful of custom roles. Once the roles were set up, the plugin was deactivated (it doesn't need to be active for the roles to exist) and all the caps for the roles are controlled via a custom plugin.
However, since the last plugin update, it looks like the wp_user_roles
entry in the database has been updated, and administrator-level users now have access to the file editor for themes plugins, despite DISALLOW_FILE_EDIT
still being defined as true.
I added a filter to one of my plugins that basically does the same thing as wp-includes/capabilities.php
:
function vnmAdmin_preventFileEdits($required_caps, $cap, $user_id, $args) {
$blocked_caps = array(
'edit_files',
'edit_plugins',
'edit_themes',
);
if (in_array($cap, $blocked_caps)) {
$required_caps[] = 'do_not_allow';
}
return $required_caps;
}
add_filter('map_meta_cap', 'vnmAdmin_preventFileEdits', 10, 4);
...but this still doesn't work. No matter what I do, I can't remove the edit_files/themes/plugins
ability from administrator users. And I definitely want to.
Is there anything else I'm missing here?
Topic constants user-roles wp-config Wordpress
Category Web