0

I'm looking for adding a custom css in the admin panel by targeting user id cause I have another administrator but I want to hide something from him by css. I'm using this code to put some stylesheet files in the admin panel, but its for all users

add_action('admin_head', 'my_custom_fonts');

function my_custom_fonts() {
  echo '  <link rel="stylesheet" type="text/css" href="../../admincss.css?v=1.3">';
}

2 Answers 2

0

Use below code into functions.php file. Make sure you are using it right way use admin_enqueue_scripts

add_action('admin_enqueue_scripts', 'FUNCTION_NAME');function FUNCTION_NAME() {
 global $current_user;
 $user_id = get_current_user_id();
 if(is_admin() && $user_id == '2'){
    wp_enqueue_style( 'admin_css', get_template_directory_uri() . '/admin-style.css', false, '1.0.0' );
}}
-1

done it

add_action('admin_head', 'my_custom_fonts');

function my_custom_fonts() {
     global $current_user;
 $user_id = get_current_user_id();
if(is_admin() && $user_id == '2'){
    echo '  <link rel="stylesheet" type="text/css" href="../../new.css">';
    }


}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.