Hide the MonsterInsights Dashboard Widget
Removes the MonsterInsights reports widget from the WordPress dashboard for everyone except administrators, or for all users.
Opens WPIDE on
Code
$wpide_everyone = false; // true = remove for all users.
add_action( 'wp_dashboard_setup', function () use ( $wpide_everyone ) {
if ( ! function_exists( 'MonsterInsights' ) && ! function_exists( 'monsterinsights_get_option' ) ) {
return;
}
if ( $wpide_everyone || ! current_user_can( 'manage_options' ) ) {
remove_meta_box( 'monsterinsights_reports_widget', 'dashboard', 'normal' );
remove_meta_box( 'monsterinsights_reports_widget', 'dashboard', 'side' );
}
}, 999 );
Notes
Set $wpide_everyone to true to remove it for administrators too.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.