以下是两种方法:
方法1可以移除整个Right Now
仪表板中的metabox:
function custom_dashboard() {
if(!current_user_can(\'manage_options\')){
// only remove it for non-admins
remove_meta_box(\'dashboard_right_now\', \'dashboard\', \'core\');
}
}
add_action(\'admin_init\',\'custom_dashboard\');
然后添加另一个自定义
Right Now
具有自定义代码的metabox。例如,您可以查看Wordpress函数
wp_dashboard_right_now()
位于
/wp-admin/includes/dashboard.php
.
方法2可以隐藏.table_content
和.table_discussion
通过CSS的部件:
function custom_css() {
if(!current_user_can(\'manage_options\')){
// only hide it for non-admins
echo "<style>#dashboard_right_now .table_content, #dashboard_right_now .table_discussion {display:none !important;}</style>";
}
}
add_action(\'admin_head-index.php\',\'custom_css\');
metabox的外观与仪表板中的类似: