How to alert network admin when a subsite has low available space

Since part of my job is to support a very, very large multisite (and multiuser) WordPress installation, I deal daily with user’s requests and problems.

One of the most frustrating things for them and me, is when the available space of their blog is low. They have to report it to our helpdesk and then wait till we increase it.

Since I couldn’t find a plugin which notice the network admin about low space in subblogs,  I wrote a simple function which does it.

The function sends an email to the network admin when the available space is less then 200MB. It runs every time the blog admin visits the control panel of his/her’s blog.
Just add the following code in your custom.php file.

* Send email to super admin when the blog's available space is less than 200MB
function ls_blog_space_mail() {
$space_left = round( get_upload_space_available() / 1024 / 1024 );
if ( $space_left < 200 ) {
$message = 'Site ' . get_site_url() . ' has only ' . $space_left . 'MB space left. '
. 'If you wish to expand the available space visit ' . network_admin_url( 'site-settings.php?id=' . get_current_blog_id() ) . ' and increase the "' . __( 'Site Upload Space Quota' ) . '."';
wp_mail( get_site_option( 'admin_email' ), "[ " . wp_specialchars_decode( get_option( 'blogname' ) ) . " ]. Low available space", $message );

if ( is_multisite() ) {
add_action( 'activity_box_end', 'ls_blog_space_mail' );

Or find it in github


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s