• gbuckingham89

    (@gbuckingham89)


    Hi there,

    I’m using the following code to add an options panel to my site. Administrators can view the options page and make changes. However, editors can not – they can view the page, but when they try to save anything, they just get greeted with the Cheatin’ uh?” error message. I would just change their role, however I’m using another plugin were they have to be editors.

    Any advice on letting them save settings?

    // Hook in
    add_action('admin_menu', 'mv_admin_menu');  
    
    // Add admin menu for options
    function mv_admin_menu() {
        add_menu_page('my settings title', 'Settings', 'edit_posts', 'mv_options_page', 'mv_options_page');
        add_action('admin_init', 'mv_register_settings');
    }  
    
    // Register the settings
    function mv_register_settings() {
        register_setting('xx-options-group', 'xxx_opt1');
    } 
    
    // Output the options page
    function mv_options_page() {
    	?>
    	<div class="wrap">
    	<h2>Moors Valley Settings</h2>
    	<?php if($_GET['settings-updated']==true) { echo '<p><strong>You changes have been saved.</strong></p>'; } ?>
    	<form method="post" action="options.php">
    	    <?php settings_fields('xx-options-group'); ?>
    	    <table class="form-table">
    	        <tr valign="top">
    		        <th scope="row">Option 1:</th>
    		        <td><input style="width:300px;" type="text" name="xxx_opt1" value="<?php echo get_option('xxx_opt1'); ?>" /></td>
    	        </tr>
    	    </table>
    	    <p class="submit">
    	    <input type="submit" class="button-primary" value="Save Changes" />
    	    </p>
    	</form>
    	</div>
    	<?php
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gbuckingham89

    (@gbuckingham89)

    Update…

    I tried granting the “editor” role the capability to “manage_options”. However this then shows all the other options under the Settings menu that I don’t want them to have access to.

    I’m now granting the “manage_options” capability to “editor”, detecting if the current user is an editor, and if they are, I’m removing the “Settings” menu and submenu. At the moment this is the only solution I can think of.

    Anyone have an idea for a better solution?

    I’m having the exact same issue. It would be nice if register_settings took an optional “capabilities” argument.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Editor can't edit options’ is closed to new replies.