Don’t put it in your theme’s functions.php file. If you switch themes, you lose the functionality.
Read this blog post: https://wphidedash.org/2011/04/best-practice-for-adding-custom-functions/
It tells you how to create a custom plugin for these functions. Make sure you change the info in the plugin header to reflect your name and site URL.
Now, for the code you need to add to that custom plugin to do this:
/* Disable default dashboard widgets */
function spiffy_disable_default_dashboard_widgets() {
if ( !is_super_admin() ) {
remove_meta_box( 'dashboard_right_now', 'dashboard', 'core' );
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'core' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'core' );
remove_meta_box( 'dashboard_plugins', 'dashboard', 'core' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'core' );
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'core' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'core' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'core' );
}
}
add_action('admin_menu', 'spiffy_disable_default_dashboard_widgets');
Be sure to remove the code from your functions.php file before activating the custom plugin.
Notice that I’ve prefixed the function name with spiffy_ – that’s to keep it from conflicting with any other functions that might have the same name. It’s always best to do that. ??