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

functions - Remove check boxes and its label from screen option for custom role

programmeradmin0浏览0评论

I want to hide many check boxes and its label in screen option only for custom user role (wdm_instructor and group_leader). How to apply below code so its for custom user role only:

add_action( 'admin_head', 'remove_wordpress_cfields' );

function remove_wordpress_cfields() { 
    echo '<style>label[for=wpassetcleanup_asset_list-hide] { display: none; }</style>';
}

any help really appreciate

I want to hide many check boxes and its label in screen option only for custom user role (wdm_instructor and group_leader). How to apply below code so its for custom user role only:

add_action( 'admin_head', 'remove_wordpress_cfields' );

function remove_wordpress_cfields() { 
    echo '<style>label[for=wpassetcleanup_asset_list-hide] { display: none; }</style>';
}

any help really appreciate

Share Improve this question asked Jul 12, 2020 at 3:41 jasawebjasaweb 519 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can check the current user role in the same action and apply "display none" for that specific user role

$user = wp_get_current_user();
if ( in_array( 'author', (array) $user->roles ) ) {
  //The user has the "author" role
}
发布评论

评论列表(0)

  1. 暂无评论