Home / Admin / Hide Menu Exception
Duplicate Snippet

Embed Snippet on Your Site

Hide Menu Exception

Visually hide but retain all functions intact under hood. Helps reduce unintended human errors.

Code Preview
php
<?php
// Hide Menu Exception / Kiri Vadivelu / 2026
add_action( 'admin_menu', 'hide_menu_except' );
// Visually hide but retain all functions intact
function hide_menu_except() {
    $current_user_id = get_current_user_id();
    // Only apply if the user is NOT User ID 1
    if ( $current_user_id != 1 ) {
        // Remove Appearance menu (themes.php)
        remove_menu_page( 'themes.php' );
        // Remove Theme/ Plugin editor (tools.php)
        remove_menu_page( 'tools.php' );
        // Remove Settings menu (options-general.php)
        remove_menu_page( 'options-general.php' );
    }
}    

Comments

Add a Comment