Change WordPress user roles and capabilities Forums New Feature Request Custom backend CSS applied for custom role?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5036
    hkunkun
    Participant

    Hi,

    Can we create custom backend CSS that will be applied for custom logged in user role?

    Thanks!

    #5037
    Vladimir
    Keymaster

    Yes, we can. There is a hook to add additional option for roles.
    Code below adds “Add custom CSS” additional option. Custom CSS will be added to the backend for the selected role once you turn this option ON for it.

    
    add_filter('ure_role_additional_options', 'ure_custom_backend_css_option', 10, 1);
    
    function ure_custom_backend_css_option($items) {
        $item = URE_Role_Additional_Options::create_item('custom_backend_css', esc_html__('Add custom CSS', 'user-role-editor'), 'admin_init', 'ure_add_custom_backend_css');
        $items[$item->id] = $item;
        
        return $items;
    }
    
    function ure_add_custom_backend_css() {
    
      add_action('admin_head', 'ure_custom_backend_css');
    
    }
    
    function ure_custom_backend_css() {
    ?>
       <style>
          # URE custom CSS here
       </style>
    <?php                    
    }
    

    I set this code as a Must Use plugin for testing.

    #5041
    hkunkun
    Participant

    Thanks for the reply!

    One more thing (sorry if it’s off topic), I can manage which admin menus are showing for a specific role, so can I also do a custom order for them too?

    Many thanks.

    #5042
    Vladimir
    Keymaster

    There is no custom order functionality for admin menu in User Role Editor Pro.
    Look at Admin menu editor plugin.

    #5045
    hkunkun
    Participant

    Thanks for the reply.

    I meet another problem, installing the new plugin that comes with an admin menu, but it’s not appeared in the “admin menu” list. (It appeared in the backend admin as I’m a super admin but not other roles).

    I think is it the problem when User Role Editor haven’t update the admin menu item yet? And how to fix it?

    Thanks.

    #5047
    Vladimir
    Keymaster

    URE shows full admin menu for the ‘administrator’ role only. URE shows admin menu items to which selected role has access only – for all other roles.

    Do you see mentioned menu item if you open “Admin menu” for the “administrator” role? Look what capability protects needed menu item there. It will appear at the “Admin menu” for other role after you will grant that capability to a role.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.