[wp-edu] Admin notification for low space in subsites

Stergatou Eleni stergatu at cti.gr
Tue Dec 6 08:16:56 UTC 2016


Hi.
We made a small snippet which notifies the superadmin via email in case of a subsite has less than 200MB space left.

Maybe this can be useful for some of you also. Just add it in the custom.php of your installation.


/**
* 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' );
}


You can find the function also  in https://github.com/lenasterg/wpms_snippet/blob/master/alert_netadmin_low_blog_space


Best regards,
Lena Stergatou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.automattic.com/pipermail/wp-edu/attachments/20161206/207f8bb9/attachment.html>


More information about the wp-edu mailing list