# Hide Admin Menu Items From Non-Administrators

> Removes selected menu entries (Tools and Comments by default) for every user who is not an administrator, to keep the admin menu focused.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: menu, roles, clean-up
- Author: WPIDE Team
- Installs: 6
- Updated: 2026-10-28
- Page: https://wpide.com/library/hide-admin-menu-items-for-non-admins/

## Code

```php
add_action( 'admin_menu', function () {
    if ( current_user_can( 'manage_options' ) ) {
        return;
    }

    // Menu slugs to hide. Examples: 'edit-comments.php', 'tools.php', 'upload.php', 'edit.php?post_type=page'.
    $hidden = array( 'tools.php', 'edit-comments.php' );

    foreach ( $hidden as $slug ) {
        remove_menu_page( $slug );
    }
}, 999 );
```

## Notes

Hiding a menu item does not remove the permission; users can still open the screen by URL if their role allows it.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide Admin Menu Items From Non-Administrators" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
