Question

I have disabled the registered users to select the admin color scheme as I want all of them to use the 'Coffee' scheme. I have also made the 'Coffee' color scheme the default one for registered users.

However, WordPress still shows the default (black) admin bar for nonregistered/nonlogged users of the website.

Do you know how I can force it show the admin bar in the 'Coffee' color scheme even in those cases?

Thank you very much in advance.

Was it helpful?

Solution 2

Problem has now been solved using the following code in functions.php

function your_custom_function_name()

{

echo '<link rel="stylesheet" href="' . admin_url('css/colors/coffee/colors.css') . '" type="text/css">';

}

add_action('admin_print_styles', 'your_custom_function_name');

add_action('wp_print_scripts', 'your_custom_function_name');

Keep in mind the code above works for the 'Coffee' color scheme. If you want to use any of the other color scheme, you need to change the admin_url(parameter) to reference the correct directory.

And if you haven't yet set the desired color scheme as default for all users, you can use this piece of code (again, in functions.php)

function your_other_custom_function_name($user_id) {

    $args = array(

    'ID' => $user_id,

    'admin_color' => 'coffee'

    );

    wp_update_user( $args );

    add_action('user_register', 'your_other_custom_function_name');

}

Once again, you need to change the 'admin_color' => 'parameter' to match your desired color scheme

OTHER TIPS

Follow these steps:

  1. Use the following code in your functions.php or your site specific plugin:

    function set_default_admin_color($user_id) {
        $args = array(
            'ID' => $user_id,
            'admin_color' => 'coffee'
        );
        wp_update_user( $args );
    }
    add_action('user_register', 'set_default_admin_color');
    
  2. Now, add these lines to force "Coffee" color scheme to be displayed in the admin bar:

    if ( !current_user_can('manage_options') )
    remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
    
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top