# Warn When There Are Too Many Administrators

> Shows a dashboard notice listing the administrator accounts when there are more than you expect, a prompt to downgrade old or unused ones.

- Type: PHP
- Runs: Admin only
- Category: [Security](https://wpide.com/library/category/security/)
- Tags: security, users, notices
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/warn-too-many-administrators/

## Code

```php
// Highest number of administrators you consider normal.
$wpide_max_admins = 3;

add_action( 'admin_notices', function () use ( $wpide_max_admins ) {
    $screen = get_current_screen();

    if ( ! $screen || 'dashboard' !== $screen->id || ! current_user_can( 'list_users' ) ) {
        return;
    }

    $admins = get_users( array( 'role' => 'administrator', 'fields' => array( 'user_login' ), 'number' => 50 ) );

    if ( count( $admins ) <= $wpide_max_admins ) {
        return;
    }

    printf(
        '<div class="notice notice-warning"><p><strong>%1$d administrator accounts:</strong> %2$s. Give people the lowest role they need. <a href="%3$s">Review administrators</a>.</p></div>',
        count( $admins ),
        esc_html( implode( ', ', wp_list_pluck( $admins, 'user_login' ) ) ),
        esc_url( admin_url( 'users.php?role=administrator' ) )
    );
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Warn When There Are Too Many 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/
