upload_is_user_over_quota() WordPress Function

The upload_is_user_over_quota() function checks whether a user has exceeded their upload quota. If the user has exceeded their quota, the function returns true. Otherwise, the function returns false.

upload_is_user_over_quota( bool $display_message = true ) #

Check whether a site has used its allotted upload space.


Parameters

$display_message

(bool)(Optional) If set to true and the quota is exceeded, a warning message is displayed.

Default value: true


Top ↑

Return

(bool) True if user is over upload space quota, otherwise false.


Top ↑

Source

File: wp-admin/includes/ms.php

function upload_is_user_over_quota( $display_message = true ) {
	if ( get_site_option( 'upload_space_check_disabled' ) ) {
		return false;
	}

	$space_allowed = get_space_allowed();
	if ( ! is_numeric( $space_allowed ) ) {
		$space_allowed = 10; // Default space allowed is 10 MB.
	}
	$space_used = get_space_used();

	if ( ( $space_allowed - $space_used ) < 0 ) {
		if ( $display_message ) {
			printf(
				/* translators: %s: Allowed space allocation. */
				__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
				size_format( $space_allowed * MB_IN_BYTES )
			);
		}
		return true;
	} else {
		return false;
	}
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.