Widgets capability for Editors

  • Sylaxo

    #10555

    Hi,

    I would like the Editors to freely access the Widgets page in the dashboard panel.

    The Restrict widgets plugin does it perfectly but it adds unnecessary lengthy settings everytime it is used (hide or display a widget on individual pages and posts).

    Can anyone suggest another solution?

    Thanks.

    Mod

    Kenneth John Odle

    #46411

    There are plugins that will allow you to edit a role’s capabilities. Alternately, you can change their capabilities by editing the database. I forget how, exactly (haven’t had to do this in ages), but it is googleable.

    Sylaxo

    #46412

    Thank you for your reply.

    I did some Google research.

    I found:

    I copied and pasted the code in the child-theme’s functions.php, so it is now :

    <?php
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parent-style' ) );
    }
    $role = get_role('editor');
    $role->add_cap('edit_theme_options');

    function custom_admin_menu() {

    $user = new WP_User(get_current_user_id());
    if (!empty( $user->roles) && is_array($user->roles)) {
    foreach ($user->roles as $role)
    $role = $role;
    }

    if($role == "editor") {
    remove_submenu_page( 'themes.php', 'themes.php' );
    remove_submenu_page( 'themes.php', 'nav-menus.php' );
    }
    }

    add_action('admin_menu', 'custom_admin_menu');
    ?>

    First time in my life I venture into a php file!

    The result is the Appearance menu is now accessible to Editors with the following submenus :

    customize, widgets, header, background, Graphene options !!! and Graphene FAQ.

    I want only Widgets to be accessible.

    It was the case with the Restrict widgets plugin, the Appearance menu offered only the Widget possibility. But I mentioned earlier Restrict widgets may be a bit inconvenient for the 5 or 6 Editors I have to train.

    I have tested User Role Editor and Capability Manager Enhanced but I saw nowhere any mention of widgets.

    I read that Members created the same problem that I mentioned : too many capabilities

    Thank you for your help. If I can’t find a better solution, Restrict Widgets will be a quite acceptable choice.

    Sylaxo

    #46413

    As I was dissatisfied with the result I deleted my addition to the functions.php file.

    But this did not disactivate the changes…

    After a few difficult hours I remembered that User Role Editor had a button to reset a role to its original “core” state.

    Phew!

    Where had the changes been implemented after vanishing from the functions file ?

    Mod

    Kenneth John Odle

    #46414
    Quote:
    Where had the changes been implemented after vanishing from the functions file ?

    The above code (and these plugins, as well) actually make a change to the WordPress database. Hitting the reset button with User Role Editor actually removes those changes from the database.

    Sylaxo

    #46415

    Thanks again.

    I have reactivated Restrict widgets.

    I consider the subject has been resolved.

Viewing 6 posts - 1 through 6 (of 6 total)

  • You must be logged in to reply to this topic.