$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>custom css in admin panel by user id|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

custom css in admin panel by user id

matteradmin7PV0评论

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">';
}

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">';
}
Share Improve this question asked Nov 23, 2018 at 5:01 Gamal ElwazeeryGamal Elwazeery 259 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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' );
}}

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">';
    }


}

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far