Run function for specific user only

I’ve created following function to run a stylesheet for the admin area, but I want to runt it only for ‘shop_manager’ this user role and for others, it should not make any modifications from that stylesheet.

// Update CSS within in Admin
function admin_style() {
if (current_user_can( ‘administrator’ ) ) {
return admin_style();
wp_enqueue_style(‘admin-styles’, get_stylesheet_directory_uri().’/admin.css’);
add_action(‘admin_enqueue_scripts’, ‘admin_style’);

Problem with it is, when I put shop_manager in user role section it loads only shop_manager’s admin dashboard and not the Administrator’s. And when I add ! current_user_can it happens the same but vice versa. Please help!!

Read more here:: Run function for specific user only

Leave a Reply

Your email address will not be published. Required fields are marked *