Site Health is a nice tool that exists on WordPress since v.5.2 and monitors the health of your site, notifying you of any issues or improvements that should be made. While it is a great feature that helps you improve your site, not everybody like it and quite a few actually hate it. You see, if you are not the only Admin in your site, and especially if the other Admin is your client, you wouldn’t like them to witness a warning that something is wrong with their site.

So, soon after its appearance, a lot of tutorials came up explaining how to remove Site Health from your WordPress dashboard and new plugins made it even easier. Actually, all you have to do is put this in your functions.php :

add_action( 'wp_dashboard_setup', 'remove_site_health_widget' );
function remove_site_health_widget() {
        global $wp_meta_boxes;
        unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health'] );
}

add_action( 'admin_menu', 'remove_site_health_submenu', 999 );
function remove_site_health_submenu() {
        $page = remove_submenu_page( 'tools.php', 'site-health.php' );
}

The fist action will remove the dashboard widget and the second one will remove the option from the menu.

While I can understand the need to do so, though, I find such a drastic measure to be wrong. After all, in an ideal world, site Admins should be those who are actually involved in the site’s development. Data entry and content management should be assigned to users with no more privileges than those of an Editor or, (in the case of an e-shop) a Shop Manager. Obviously, in real life that cannot always be the case.

What’s the alternative, then?

Simple: Instead of completely removing the functionality for everyone, why not hide it from everyone else except yourself? All you have to do is identify the currently logged-in user and if he/she is not you, run the aforementioned functions. You can easily check if the currently logged in user is you by comparing your id with theirs like so:

function is_the_chosen_one() {
    $techie_id  = 1; // your ID
    $current_id = get_current_user_id();

    return ! ( $techie_id && $current_id !== $techie_id );
}

The function is_the_chosen_one() will return true if the current user is the Chosen One and with that, our full code would look like that:

// Remove Site Health widget from Dashboard
add_action( 'wp_dashboard_setup', 'remove_site_health_widget' );
function remove_site_health_widget() {
    if(is_the_chosen_one()) {
        global $wp_meta_boxes;
        unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health'] );
    }
}

// Remove Site Health menu entry
add_action( 'admin_menu', 'remove_site_health_submenu', 999 );
function remove_site_health_submenu() {
    if(is_the_chosen_one()) {
        $page = remove_submenu_page( 'tools.php', 'site-health.php' );
    }
}

// Check if the current user is the Chosen One
function is_the_chosen_one() {
    $techie_id  = 1; // Your ID
    $current_id = get_current_user_id();

    return ! ( $techie_id && $current_id !== $techie_id );
}

If you prefer to use a plugin instead of copying and pasting the code on your site, I’ve included it on Slash Admin under the Administration → Admin overrides tab. There, you can select your tech-savvy user (called “Techie”) who will be the only one with access to a few special functionalities of the Admin, with Site Health being one of them.

Site health is your friend, not your enemy, as it can warn you about potential issues on your site. Instead of hating it and removing it completely from your site, why not keep it visible only to those who can appreciate its value, which should be none other but you?

Leave a Reply

Your email address will not be published. Required fields are marked *