# Hide Comments in the Admin From Users Who Cannot Moderate

> Removes the Comments menu, admin bar bubble and screen for users without moderation rights, such as authors and contributors.

- Type: PHP
- Runs: Run everywhere
- Category: [Comments](https://wpide.com/library/category/comments/)
- Tags: comments, admin, permissions
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/hide-comments-admin-non-moderators/

## Code

```php
add_action( 'admin_menu', function () {
    if ( ! current_user_can( 'moderate_comments' ) ) {
        remove_menu_page( 'edit-comments.php' );
    }
}, 999 );

add_action( 'admin_bar_menu', function ( $wp_admin_bar ) {
    if ( ! current_user_can( 'moderate_comments' ) ) {
        $wp_admin_bar->remove_node( 'comments' );
    }
}, 999 );

add_action( 'load-edit-comments.php', function () {
    if ( ! current_user_can( 'moderate_comments' ) ) {
        wp_safe_redirect( admin_url() );
        exit;
    }
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide Comments in the Admin From Users Who Cannot Moderate" 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/
