There’s a few questions on this site referencing this issue and I’ve read them and applied the proposed solutions to no avail.
I’ve made a very simple theme options page that appears for the Editor role but when an Editor tries to save the options they get the “Cheatin ‘Uh?” message.
The following is my options code:
<?php
function map_register_settings() {
add_option( 'map_zoom', '1');
add_option( 'map_longitude', 'alpha');
register_setting( 'default', 'map_zoom' );
register_setting( 'default', 'map_longitude' );
register_setting( 'default', 'map_latitude' );
}
add_action( 'admin_init', 'map_register_settings' );
function map_register_options_page() {
add_theme_page('Map Center', 'Map Center', 'edit_theme_options', 'map-options', 'map_options_page');
}
add_action('admin_menu', 'map_register_options_page');
function map_options_page() {
?>
<div class="wrap">
<h2>Map Center Options</h2>
<form method="post" action="options.php">
<?php settings_fields( 'default' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="map_zoom">Zoom Level (1 - 21):</label></th>
<td>
<input type="text" id="map_zoom" name="map_zoom" value="<?php echo get_option('map_zoom'); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="map_latitude">Latitude:</label></th>
<td><input type="text" id="map_latitude" name="map_latitude" value="<?php echo get_option('map_latitude'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="map_longitude">Longitude:</label></th>
<td><input type="text" id="map_longitude" name="map_longitude" value="<?php echo get_option('map_longitude'); ?>" /></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
}
?>
I’ve also added the following to my functions file in an attempt to give the editor role the necessary capability:
//ALLOW EDITOR TO CHANGE MAP CENTER
// get the the role object
$editor = get_role('editor');
// add $cap capability to this role object
$editor->add_cap('edit_theme_options');
There’s a bug(ish) report regarding this here:
http://make.wordpress.org/themes/2011/07/01/wordpress-3-2-fixing-the-edit_theme_optionsmanage_options-bug/
You can use a filter to modify the theme page capability. First you’ll want to edit your
register_setting()
calls to look like this:The first parameter is the settings group and this is what we’re filtering the capabilities for.
Second is to add the filter:
That should do it.
You may be able to use the customiser instead if it makes sense to, not sure if editors can use that off the top of my head though.
This plugin may help. Allows you to edit, create, and delete roles as well as capabilities for these roles.