Filter hook 'wp_handle_upload'

in WP Core File wp-includes/functions.php at line 2977

View Source

wp_handle_upload

Filter Hook
Description
Filters whether to treat the upload bits as an error. Returning a non-array from the filter will effectively short-circuit preparing the upload bits and return that value instead. An error message should be returned as a string.

Hook Information

File Location wp-includes/functions.php View on GitHub
Hook Type Filter
Line Number 2977

Hook Parameters

Type Name Description
array|string $upload_bits_error An array of upload bits data, or error message to return.

Usage Examples

Basic Usage
<?php
// Hook into wp_handle_upload
add_filter('wp_handle_upload', 'my_custom_filter', 10, 1);

function my_custom_filter($upload_bits_error) {
    // Your custom filtering logic here
    return $upload_bits_error;
}

Source Code Context

wp-includes/functions.php:2977 - How this hook is used in WordPress core
<?php
2972  	if ( is_multisite() ) {
2973  		clean_dirsize_cache( $new_file );
2974  	}
2975  
2976  	/** This filter is documented in wp-admin/includes/file.php */
2977  	return apply_filters(
2978  		'wp_handle_upload',
2979  		array(
2980  			'file'  => $new_file,
2981  			'url'   => $url,
2982  			'type'  => $wp_filetype['type'],

PHP Documentation

<?php
/**
	 * Filters whether to treat the upload bits as an error.
	 *
	 * Returning a non-array from the filter will effectively short-circuit preparing the upload bits
	 * and return that value instead. An error message should be returned as a string.
	 *
	 * @since 3.0.0
	 *
	 * @param array|string $upload_bits_error An array of upload bits data, or error message to return.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/functions.php
Related Hooks

Related hooks will be displayed here in future updates.