最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

admin css - Run function for specific user only

programmeradmin4浏览0评论

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!!

发布评论

评论列表(0)

  1. 暂无评论