Change user capability
-
I have a plugin that I created that works great with admin but when I try to use it as an editor, I get the message that I cheated and don’t have the right to make these changes. I put in the options page the edit_pages capability which allowed the plugin to show up but if I try to enable the banner and save it. I get the error message.
This plugin just activates a banner in the heading section of a web page allowing to customize the background color and the text to be displayed as well as to whether it should be enabled or disabled (show up on the page or not). I would like the editor to be able to set this as well as the admin. Here is my code:
<?php // Create Options Menu Link function enb_options_menu_link(){ add_options_page( 'Emergency Banner Options', 'Emergency Banner Settings', 'edit_pages', 'enb-options', 'enb_options_content' ); } // Create Content function enb_options_content(){ // Init Global Options global $enb_options; //Get the color value; $color = $enb_options['color']; ?> <div class="wrap"> <h1>Emergency Banner Settings</h1> <h2>Settings for the Emergency Banner plugin</h2> <form method="post" action="options.php"> <?php settings_fields('enb_settings_group'); ?> <table class="form-table enb-table"> <tbody> <tr> <th scope="row"><label for="enb_settings[important_news]"><?php _e('Emergency News:','enb-domain');?></label> </th> <td><input name="enb_settings[important_news]" type="text" id="enb_settings[important_news]" value="<?php echo $enb_options['important_news']; ?>" class="regular-text"> <p class="description" id="enb_settings[important_news]"><?php _e('Enter your Emergency or Important news here', 'enb-domain');?></p></td> </tr> <tr> <th scope="row"><label for="enb_settings[enabled]"><?php _e('Enable Emergency Banner:','enb-domain');?></label> </th> <td><input name="enb_settings[enabled]" type="checkbox" id="enb_settings[enabled]" value="1" <?php checked('1', $enb_options['enabled']); ?> > </td> </tr> <tr> <th scope="row"><label for="enb_settings[color]"><?php _e('Select Emergency Banner color:','enb-domain');?></label> </th> <td><input name="enb_settings[color]" type="radio" id="enb_settings[color]" value="red" <?php if(isset($color) && $color=="red" || !isset($color)) echo "checked"; ?> >Red <input name="enb_settings[color]" type="radio" id="enb_settings[color]" value="yellow" <?php if(isset($color) && $color=="yellow") echo "checked"; ?> >Yellow <input name="enb_settings[color]" type="radio" id="enb_settings[color]" value="green" <?php if(isset($color) && $color=="green") echo "checked"; ?> >Green </td> </tr> </tbody> </table> <p class="submit"><input type="submit" name="submit" id="submit" class="button btn" value="<?php _e('Save Changes', 'enb-domain');?>"></p> </form> </div> <?php } add_action('admin_menu', 'enb_options_menu_link'); // Register Settings function enb_register_settings(){ register_setting('enb_settings_group', 'enb_settings'); } add_action('admin_init', 'enb_register_settings');
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Change user capability’ is closed to new replies.