how to get an admin theme to only load for 'author'? (4 posts)

  1. cerysjones
    Posted 4 years ago #

    Hey all,

    I'm working on an admin theme, got the CSS to load fine, but I want it to either only load for roles other than 'admin' or to only load for the role of 'author'.

    Either will do for my purposes, but I can't seem to get it to work.

    The code that I'm using to load the stylesheet is pretty standard, as follows:

    function new_admin_css() {
    	echo '<link rel="stylesheet" type="text/css" href="' . get_settings('siteurl') . '/wp-content/plugins/new-admin/lib/wp-admin.css?version=1.02" />';
    add_action('admin_head', 'new_admin_css');

    I've tried using some basic conditional statements, but it's been several years since I coded any serious PHP and I'm having to slowly re-learn it, so anyone who could point me in the right direction would be much appreciated!


  2. Boyevul
    Posted 4 years ago #

    Try the following plugin:
    Theme Test Drive

  3. cerysjones
    Posted 4 years ago #

    Thanks, but the problem is with an admin theme - it's a theme for the backend, the dashboard, not the public site!

  4. colosimo
    Posted 4 years ago #

    If anyone interested, add this code to your functions.php.
    Just adjust the user level for your needs.
    This example uses admin.css in your template folder for all users and editor.css just for editors.

    function custom_admin_style() {
      printf('<link rel="stylesheet" type="text/css" href="%s/admin.css" />',get_bloginfo('template_url'));
      global $current_user; get_currentuserinfo(); if ( $current_user->user_level < 9 ) {
      printf('<link rel="stylesheet" type="text/css" href="%s/editor.css" />',get_bloginfo('template_url'));}
    add_action('admin_head', 'custom_admin_style');

Topic Closed

This topic has been closed to new replies.

About this Topic