Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');
share|improve this question

2 Answers 2

This plugin may help. Allows you to edit, create, and delete roles as well as capabilities for these roles.

share|improve this answer
    
Thanks, it's not precisely what I was looking for but it did solve the problem. It resulted in my having to hide certain menu items from the dashboard for the editor role. I would have preferred having them totally not accessible rather then just hidden though. –  Ciaran Sep 19 '13 at 7:40

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:

register_setting( 'map-options', 'map_zoom' ); 
register_setting( 'map-options', 'map_longitude' ); 
register_setting( 'map-options', 'map_latitude' ); 

The first parameter is the settings group and this is what we're filtering the capabilities for.

Second is to add the filter:

add_filter( 'option_page_capability_map-options', 'sewp_114719_map_options_capability' );
function sewp_114719_map_options_capability( $cap ) {
    return 'edit_theme_options';
}

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.