Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1217777
    FamSantePr
    Participant

    Howdy !

    We have a questions that is more about WordPress, but since there are wordpress developers at Themeco, we thought we might be able to get some help …

    We are looking to give access to the sidebars to editors. Could you please help us ?

    We have found this page, but are afraid to test it : http://wordpress.stackexchange.com/questions/28416/give-editor-access-to-sidebar

    We are no developers, so a hint would great, thanks !

    #1217902
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! Because what you are trying to accomplish requires a template customization, we would like to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    After the child theme is set up, please add the following code in your child theme’s functions.php file

    function custom_admin_menu() {
    
       $role = get_role('editor'); 
       $role->add_cap('edit_theme_options');
    
        $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');

    Hope this helps. Please let us know how it goes.

    #1218137
    FamSantePr
    Participant

    Hello !

    You guys are awesome. Child theme is indeed set up now.

    Where in the functions.php file should we add this code please ? Top ? Bottom ? Middle ?
    Before or after any other batch of code ?

    Many thanks for your help !

    #1218145
    Thai
    Moderator

    Hi There,

    The code should be added at the end of the functions.php file.

    Regards!

    #1218149
    FamSantePr
    Participant

    Hi ! Sorry but it DOES NOT WORK completely.

    Allow us to break it down :
    1. What we did
    In WordPress we went to Apparences (where “themes” is located), under EDITOR, chose the child theme activated, and then chose the “functions.php” to add code there, directly from WordPress.
    2. The effects
    In the editor, the “sidebar” page appears in Apparences (where themes is located) but when we implement the change, and save it, we get an error message “So, are you cheating ? Sorry, you do not have the authorization to modify these elements.”

    CONCLUSION
    It seems that even though the option to change the sidebar appears, something is missing to actually allow the change to be implemented.

    Did we do it well until there ? Thanks for your help. Have a nice day !

    #1218243
    FamSantePr
    Participant

    Hello again !

    ADDITIONNAL REQUEST : we also need to give access to THE MENUS to the editor (how can he choose what he’s gonna eat if we don’t ?) 😁. Could this be done as well please ?

    By doing this it would allow editors to have enough “authorization” to do their work without having access to all the rest of the WordPress security settings …

    Hope our request is clear.

    Have a nice day !

    #1218545
    Rad
    Moderator

    Hi there,

    That will remove the menu and it also remove the capability to access it. Which is correct based on the codes function. What role you’re trying to access that menu? Please provide the login credentials in private reply.

    You may want to install membership, or role editor, or any related plugins to control access by certain role. The code is simple but it can’t do all the requirements you wish to achieve. You may contact a developer since installing those plugins aren’t enough, it may still require integration and customization.

    Thanks!

    #1219914
    FamSantePr
    Participant
    This reply has been marked as private.
    #1220310
    Lely
    Moderator

    Hi There,

    I found this:https://wordpress.org/plugins/editor-menu-and-widget-access/. You might want to try that, just note that it is not officially recommended. Customization and integration questions regarding the plugin should be directed to the plugin developer. Thank you for understanding.

    #1221257
    FamSantePr
    Participant

    Ok. So, to resume it, customizing the WordPress for EDITOR roles cannot be done by changing the code, rather with a plugin, for it is too complex. Is that right ?

    #1221373
    FamSantePr
    Participant

    Hey there, the plugin works GREAT ! One thing again solved by the great ThemeCo team ! THANK YOU !

    #1221760
    Prasant Rai
    Moderator

    You are most welcome. 🙂

    #1222397
    FamSantePr
    Participant
    This reply has been marked as private.
    #1223014
    Rad
    Moderator

    Hi there,

    Working with roles and capability is a complex one, possible with code but will take long. Please try this plugin https://wordpress.org/plugins/user-role-editor/, the description says you can use it for widgets and menu.

    Thanks!

  • <script> jQuery(function($){ $("#no-reply-1217777 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>