Editor capabilities - admin_init

I'm having a little difficulties with roles and capabilities.

Editors gets a 'Cheatin uh?'-message when they try to update the custom theme-settings. Can anyone explain why - or maybe even have a solution?

?php
add_action('admin_menu', 'add_global_custom_options');
function add_global_custom_options() {
add_menu_page('Indstillinger', 'Indstillinger', 'moderate_comments', 'functions','global_custom_options');
}

add_action('admin_init', 'custom_settings_css');
function custom_settings_css() {
wp_enqueue_style('custom-settings-css', get_bloginfo('template_directory') . '/theme-files/css/custom-settings.css');
} ?

?php
function global_custom_options()
{?
div class="wrap theme-options"
    h2Indstillinger/h2
    form method="post" action="options.php"
        ?php wp_nonce_field('update-options') ?

        div class="section"
            h3Settings/h3
            p
                h4BOXIT/h4
                textarea name="box1" size="45"?php echo get_option('box1'); ?/textarea
            /p
        /div

        pinput type="submit" name="Submit" value="Gem indstillinger" //p
        input type="hidden" name="action" value="update" /
        input type="hidden" name="page_options" value="box1" /
    /form
/div
?php}?

Topic admin-init php customization Wordpress

Category Web


There is a capability called edit_theme_options which is by default assigned to only site admins not to editors. Check out - Roles Vs Capabilities .

To allow your editors to manage theme options you've to manually assign that capability to editors. Here to assign edit_theme_options capability to editors just drop in this code into your theme's functions.php file So editors can manage theme options page.

<?php

        function wpse61651_allow_editor() 
        {
            $role = get_role( 'editor' ); // pick up role to edit the editor role   
            $role->add_cap( 'edit_theme_options' ); // Let them manage our theme
        }
        add_action( 'admin_init', 'wpse61651_allow_editor');
?>

Resource -

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.