How to Remove Admin Color Scheme Options from User Profile in WordPress

Home » Snippets » How to Remove Admin Color Scheme Options from User Profile in WordPress

Created with:



Creator: WPTurbo Team

Customize with WPTurbo AI

Add Snippet To Project

New Project
Add To Existing Project

If you’re a WordPress site administrator, you may want to customize the user experience and streamline things a bit by limiting the color schemes available to users. By default, WordPress offers a range of color scheme options for users to choose from in their profiles, but you can easily remove these options to simplify your site’s backend. In this article, we’ll show you how to remove admin color scheme options from user profiles in WordPress.

					function wpturbo_remove_admin_color_scheme_options( $wp_admin_style ) {
    $wp_admin_style->colors = array();
add_action( 'admin_enqueue_scripts', 'wpturbo_remove_admin_color_scheme_options' );

The code snippet above demonstrates a technique to remove the admin color scheme options from the user profile in WordPress. This can be helpful if you want to restrict the user’s ability to change the color scheme or if you have custom branding that should not be overwritten.

The first part of the code registers a new function called wpturbo_remove_admin_color_scheme_options(). This function is what will actually remove the color scheme options.

Inside the function, we access the $wp_admin_style global variable. This variable contains information about the CSS styles that are applied to the WordPress admin area.

We set the colors property of the $wp_admin_style variable to an empty array. This effectively removes all the color schemes from the user profile.

The last step is to hook our function into the admin_enqueue_scripts action using the add_action() function. This ensures that our function is called every time the admin scripts are loaded.

When WordPress loads the admin scripts, our function is called, and the color scheme options are removed from the user profile.

Register an account to save your snippets or go Pro to get more features.