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?

4 thoughts on “How to hide WordPress’ Site Health from everyone but you

    1. Remove the “!” from the `return ! ( $techie_id && $current_id !== $techie_id );`

      So it’s this.

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

      1. Or – even better – change the two instances of `if(is_the_chosen_one())` to `if ( ! is_the_chosen_one() )` – which reads logically as it should:
        If the current user is *not* the chose one, remove the site health features.

        The suggestion above instead makes a 3 functions work the opposite way they seem like they should… which still technically works, but is confusing.

  1. The problem with Site Health is plugin authors are hijacking it and using it to notify you of what I know to be non-issues. At least the plugin says it is a ‘critical issue’ when in fact it is only a general notice and can in most cases just be ignored. So yes, I think I want to hide or even disable Site Health entirely because I will know myself when my site is sick.

Leave a Reply

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