Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save enqtran/a64e7841be3a943a7fabe3b3c7371ea7 to your computer and use it in GitHub Desktop.
Save enqtran/a64e7841be3a943a7fabe3b3c7371ea7 to your computer and use it in GitHub Desktop.
/**
* remove unwanted dashboard widgets for relevant users
*/
if ( !function_exists( 'remove_dashboard_widgets' ) ) {
function remove_dashboard_widgets() {
$user = wp_get_current_user();
if (!$user->has_cap('manage_options')) {
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
remove_meta_box('dashboard_primary', 'dashboard', 'side');
remove_meta_box('dashboard_secondary', 'dashboard', 'side');
remove_meta_box('wpseo-dashboard-overview', 'dashboard', 'normal');//xoa yoast seo overview
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'normal');
remove_meta_box('dashboard_right_now', 'dashboard', 'side');
remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
remove_meta_box('dashboard_activity', 'dashboard', 'normal');
remove_meta_box('dashboard_plugins', 'dashboard', 'normal');
}
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment