# Lock the List of Super Admins

> Blocks anyone from being granted super admin rights unless their username is on your approved list, protecting the network if a super admin account is compromised.

- Type: PHP
- Runs: Run everywhere
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: super-admin, security, permissions
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-lock-super-admin-list/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

$wpide_allowed = array( 'admin' ); // Usernames allowed to be super admins.

add_action( 'grant_super_admin', function ( $user_id ) use ( $wpide_allowed ) {
    $user = get_userdata( $user_id );

    if ( ! $user || ! in_array( $user->user_login, $wpide_allowed, true ) ) {
        wp_die( esc_html__( 'This user is not on the approved super admin list.' ), 403 );
    }
} );
```

## Notes

Add every legitimate super admin to $wpide_allowed before activating, or new grants will be refused.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Lock the List of Super Admins" 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/
