upload_is_user_over_quota

Check whether a site has used its allotted upload space.

Description

upload_is_user_over_quota( (bool) $echo = true ); 

Parameters (1)

0. $echo — Optional. (bool) => true
If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.

Usage

  1. if ( !function_exists( 'upload_is_user_over_quota' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ms.php'; 
  3.  
  4. // Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true. 
  5. $echo = true; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = upload_is_user_over_quota($echo); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ms.php  
  1. function upload_is_user_over_quota( $echo = true ) { 
  2. if ( get_site_option( 'upload_space_check_disabled' ) ) 
  3. return false; 
  4.  
  5. $space_allowed = get_space_allowed(); 
  6. if ( ! is_numeric( $space_allowed ) ) { 
  7. $space_allowed = 10; // Default space allowed is 10 MB 
  8. $space_used = get_space_used(); 
  9.  
  10. if ( ( $space_allowed - $space_used ) < 0 ) { 
  11. if ( $echo ) 
  12. _e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' ); 
  13. return true; 
  14. } else { 
  15. return false;