My goal is to hide specific tables with CSS on WordPress dashboard, from all users except super admin.
<?php is_super_admin( $user_id ); ?>
add_action( 'admin_head', 'my_custom_function' );
function my_custom_function() {
if ( ! current_user_can( 'update_core' ) ) {
echo '<style>p.smush-status {
display: none;
}
button.button.wp-smush-send {
display: none;
}
#smushit {
display:none;
}</style>';
}
});
But, when I'm adding this code to mu-plugins, I got the following error:
Fatal error: Call to undefined function wp_get_current_user() in /home/.../public_html/domain.com/wp-includes/capabilities.php on line 1614
capabilities.php it's WordPress core file.
Would you please have a look and tell me how can I improve this code?
Thank you