How to programatically remove WordPress dashboard widgets


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Simply paste the following into your functions.php file. The code will remove all dashboard widgets, so you should comment lines related to wigets you'd like to keep.
  2.  
  3. function remove_dashboard_widgets() {
  4. global $wp_meta_boxes;
  5.  
  6. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
  7. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
  8. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
  9. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
  10. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
  11. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
  12. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
  13. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
  14.  
  15. }
  16.  
  17. if (!current_user_can('manage_options')) {
  18. add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
  19. }

URL: http://www.wprecipes.com/how-to-programatically-remove-wordpress-dashboard-widgets?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Wprecipes+%28WpRecipes.com%3A+Daily+recipes+to+cook+with+WordPress%29

Report this snippet


Comments


You need to login to view comments.