# Warn Site Admins Before They Run Out of Upload Space

> Shows an admin notice on the Media screens and the dashboard once a site has used more than a set share of its upload quota, before uploads start failing.

- Type: PHP
- Runs: Admin only
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: upload-quota, storage, notices
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-storage-warning-notice/

## Code

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

$wpide_threshold = 80; // Warn above this percentage.

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

    if ( ! $screen || ! in_array( $screen->id, array( 'dashboard', 'upload', 'media' ), true ) || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) {
        return;
    }

    $allowed = (float) get_space_allowed();
    $used    = (float) get_space_used();

    if ( $allowed <= 0 || ( $used / $allowed * 100 ) < $wpide_threshold ) {
        return;
    }

    printf(
        '<div class="notice notice-warning"><p>%s</p></div>',
        esc_html( sprintf(
            'This site has used %1$d%% of its upload space (%2$s left). Delete unused media or ask the network administrator for more space.',
            min( 100, round( $used / $allowed * 100 ) ),
            size_format( (int) ( max( 0, $allowed - $used ) * MB_IN_BYTES ), 1 )
        ) )
    );
} );
```

## Notes

Change $wpide_threshold (percent). The message includes the remaining space.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Warn Site Admins Before They Run Out of Upload Space" 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/
