WordPress.org

Ready to get started?Download WordPress

Forums

Code to check user role and load custom CSS for dashboard (2 posts)

  1. ElwoodP
    Member
    Posted 1 year ago #

    I'm looking for a piece of code to place in functions.php to load a custom .css file if the user has editor role. Can someone point me in the right direction please.

    (I'm not looking for a plugin).

  2. ElwoodP
    Member
    Posted 1 year ago #

    Worked it out:

    add_action('admin_head','load_editor_style');
    load_editor_style()
    {
    $templateuri = get_template_directory_uri();
     if(current_user_can('editor')){
     wp_enqueue_style('editorstyle', $templateuri.'/css/editorstyle.css');
      }
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic