The get_space_allowed WordPress PHP filter allows you to modify the upload quota for the current site.
Usage
add_filter('get_space_allowed', 'your_function_name'); function your_function_name($space_allowed) { // your custom code here return $space_allowed; }
Parameters
- $space_allowed (int) – The upload quota in megabytes for the current blog.
More information
See WordPress Developer Resources: get_space_allowed
Examples
Increase the space allowed by 50%
add_filter('get_space_allowed', 'increase_space_allowed'); function increase_space_allowed($space_allowed) { $space_allowed = $space_allowed * 1.5; return $space_allowed; }
Set a fixed upload quota of 500 MB
add_filter('get_space_allowed', 'set_fixed_space_allowed'); function set_fixed_space_allowed($space_allowed) { $space_allowed = 500; return $space_allowed; }
Double the space allowed
add_filter('get_space_allowed', 'double_space_allowed'); function double_space_allowed($space_allowed) { $space_allowed = $space_allowed * 2; return $space_allowed; }
Reduce the space allowed by 25%
add_filter('get_space_allowed', 'reduce_space_allowed'); function reduce_space_allowed($space_allowed) { $space_allowed = $space_allowed * 0.75; return $space_allowed; }
Set different space allowed for different users
add_filter('get_space_allowed', 'set_space_allowed_based_on_user'); function set_space_allowed_based_on_user($space_allowed) { $user = wp_get_current_user(); // If the user is an administrator, set the space allowed to 1000 MB if (in_array('administrator', $user->roles)) { $space_allowed = 1000; } // If the user is an editor, set the space allowed to 500 MB elseif (in_array('editor', $user->roles)) { $space_allowed = 500; } // For other users, set the space allowed to 250 MB else { $space_allowed = 250; } return $space_allowed; }