# Network-Wide Maintenance Mode Switch

> Adds a checkbox to Network Admin > Settings that puts every site on the network into maintenance mode at once; super admins can still browse and work normally.

- Type: PHP
- Runs: Run everywhere
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: network-settings, maintenance, downtime
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-network-maintenance-mode/

## Code

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

add_action( 'wpmu_options', function () {
    ?>
    <h2><?php esc_html_e( 'Maintenance' ); ?></h2>
    <table class="form-table" role="presentation">
        <tr>
            <th scope="row"><?php esc_html_e( 'Maintenance mode' ); ?></th>
            <td><label><input type="checkbox" name="wpide_network_maintenance" value="1" <?php checked( get_site_option( 'wpide_network_maintenance' ) ); ?>> <?php esc_html_e( 'Show a maintenance page on every site to everyone except super admins' ); ?></label></td>
        </tr>
    </table>
    <?php
} );

add_action( 'update_wpmu_options', function () {
    if ( current_user_can( 'manage_network_options' ) ) {
        update_site_option( 'wpide_network_maintenance', empty( $_POST['wpide_network_maintenance'] ) ? 0 : 1 );
    }
} );

add_action( 'template_redirect', function () {
    if ( ! get_site_option( 'wpide_network_maintenance' ) || is_super_admin() ) {
        return;
    }

    header( 'Retry-After: 3600' );
    wp_die(
        '<h1>' . esc_html__( 'Down for maintenance' ) . '</h1><p>' . esc_html__( 'We are making some improvements and will be back shortly.' ) . '</p>',
        esc_html__( 'Maintenance' ),
        array( 'response' => 503 )
    );
} );

add_action( 'admin_bar_menu', function ( $bar ) {
    if ( get_site_option( 'wpide_network_maintenance' ) && is_super_admin() ) {
        $bar->add_node( array(
            'id'    => 'wpide-network-maintenance',
            'title' => '<span style="color:#f0b849">' . esc_html__( 'Network maintenance ON' ) . '</span>',
            'href'  => network_admin_url( 'settings.php' ),
        ) );
    }
}, 100 );
```

## Notes

Visitors get a 503 response with a Retry-After header, which tells search engines the downtime is temporary.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Network-Wide Maintenance Mode Switch" 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/
