Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to clean up the Admin Dashboard widgets so that only the administrator level users can see the various meta boxes, but no matter what i've tried the Broken Link Checker widget will not go away (see example code below).

I'm using WordPress 3.1 MultiSite Network and working with this code in the MU plugins folder ... not sure that matters ... i've also tried Adminimize plugin but that did not work for me on the widget either.

/* Turn off Dashboard Widgets */

if( is_admin() )
    add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );

function remove_dashboard_widgets() {
    global $wp_meta_boxes;
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['blc_dashboard_widget']);
}

Thanks in advance for any pointers ... cordially,
Chuck Scott

share|improve this question
add comment

1 Answer

The problem is probably just that your code runs before broken links checker adds the meta box. Try changing the action line to this:

if(is_admin()){
  add_action('wp_dashboard_setup', 'remove_dashboard_widgets', 1000 );
}

EDIT

To be a little more clear, the particular issue here is that the add_action() function is running super early compared to Broken Link Checker's add_action function. The two ways to fix that issue are to either run your code later (hooking your plugin's main functionality onto init and throwing your actions and filters into that init function), or increasing the precedence of your action (what I suggested above).

share|improve this answer
    
Thank you - totally worked ... i only have a couple custom functions so the priority setting of 20 did the job ... not sure if setting a priority too high like 100 or 1000 impacts load time but again, THANK YOU! –  user4014 Mar 17 '11 at 20:08
1  
No, it wouldn't affect load time at all. That just becomes the key number for the array of actions attached to 'wp_dashboard_setup', so it's equally fast to use 10, 20, 1000, or 9001. The only reason to use a higher number is to make absolutely sure that your handler runs last on the hook. –  John P Bloch Mar 17 '11 at 20:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.