add_action( 'admin_head', function () {
if ( current_user_can( 'update_core' ) ) {
return;
}
remove_action( 'admin_notices', 'update_nag', 3 );
}, 1 );
Management
Disable new user email notifications
function snipjar_new_user_notifications( $user_id, $notify = 'user' ) {
if ( empty( $notify ) || 'admin' === $notify ) {
return;
} elseif ( 'both' === $notify ) {
// Send new users the email but not the admin.
$notify = 'user';
}
wp_send_new_user_notifications( $user_id, $notify );
}
add_action(
'init',
function () {
// Disable default email notifications.
remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications' );
// Replace with custom function that only sends to user.
add_action( 'register_new_user', 'snipjar_new_user_notifications' );
add_action( 'edit_user_created_user', 'snipjar_new_user_notifications', 10, 2 );
}
);
Hide ‘Screen Options’ tab
add_filter('screen_options_show_screen', '__return_false');
Remove Dashboard widgets
function snipjar_clean_wp_dashboard()
{
remove_action("welcome_panel", "wp_welcome_panel");
remove_meta_box("dashboard_primary", "dashboard", "side");
remove_meta_box("dashboard_secondary", "dashboard", "side");
remove_meta_box("dashboard_quick_press", "dashboard", "side");
remove_meta_box("dashboard_recent_drafts", "dashboard", "side");
remove_meta_box("dashboard_php_nag", "dashboard", "normal");
remove_meta_box("dashboard_browser_nag", "dashboard", "normal");
remove_meta_box("dashboard_site_health", "dashboard", "normal");
remove_meta_box("health_check_status", "dashboard", "normal");
remove_meta_box("dashboard_activity", "dashboard", "normal");
remove_meta_box("dashboard_right_now", "dashboard", "normal");
remove_meta_box("network_dashboard_right_now", "dashboard", "normal");
remove_meta_box("dashboard_recent_comments", "dashboard", "normal");
remove_meta_box("dashboard_incoming_links", "dashboard", "normal");
remove_meta_box("dashboard_plugins", "dashboard", "normal");
}
add_action("wp_dashboard_setup", "snipjar_clean_wp_dashboard");
Hide admin notices for everyone except a specific username
function hide_admin_notices_except_specific_admin()
{
//Checking if user is on an admin page
if (is_admin()) {
//Getting the current user object
$current_user = wp_get_current_user();
//Checking if the current user has the 'administrator' role and their username is not 'specific_username'
if (
in_array("administrator", $current_user->roles) &&
$current_user->user_login !== "INSERT_USERNAME"
) {
//Removing all actions of 'admin_notices'
remove_all_actions("admin_notices");
}
}
}
//Calling the function on 'admin_init' action
add_action("admin_init", "hide_admin_notices_except_specific_admin");
Remove Comments from Frontend and Admin Area
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_safe_redirect(admin_url());
exit;
}
// Remove comments metabox from dashboard
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
// Disable support for comments and trackbacks in post types
foreach (get_post_types() as $post_type) {
if (post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
});
// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);
// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);
// Remove comments page in menu
add_action('admin_menu', function () {
remove_menu_page('edit-comments.php');
});
// Remove comments links from admin bar
add_action('init', function () {
if (is_admin_bar_showing()) {
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
}
});
Disable admin email confirmation screen
Prevent WordPress from requesting confirmation of the administrator email address upon login.
add_filter( 'admin_email_check_interval', '__return_false' );
Disable user password reset notification email
After a user resets their password, do not send the notification email to the site administrator.
remove_action( 'after_password_reset', 'wp_password_change_notification' );
Disable automatic updates emails
add_filter( 'auto_core_update_send_email', '__return_false' );
add_filter( 'auto_plugin_update_send_email', '__return_false' );
add_filter( 'auto_theme_update_send_email', '__return_false' );
Disable auto-updates for themes
add_filter( 'auto_update_theme', '__return_false' );
Disable auto-updates for plugins
add_filter( 'auto_update_plugin', '__return_false' );
Disable core auto-updates
add_filter( 'auto_update_core', '__return_false' );