How do I hide "Content" and "Discussion" element in the "Right Now" dashboard widget?
Here's a screenshot:
Here are two methods:
You could remove the whole Right Now
metabox from your dashboard:
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');
and then add another custom Right Now
metabox with your custom code. You could for example check out the Wordpress function wp_dashboard_right_now()
located in /wp-admin/includes/dashboard.php
.
You could hide the .table_content
and .table_discussion
parts via 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');
and the metabox will look similar to this one in your dashboard:
You can click on the Screen Options
in the top right of the screen, and uncheck them from the options list to disable them from your view.