• 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!

    Cx

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try the following plugin:
    Theme Test Drive

    Thread Starter cerysjones

    (@cerysjones)

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

    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');
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to get an admin theme to only load for 'author'?’ is closed to new replies.