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
2 Answers
Reset to default 0Use 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">';
}
}