WordPress filter hook · part of WordPress core

wp_delete_file

A WordPress core filter that 14 plugins also fire themselves, running on 136K+ sites between them.

“This filter is documented in wp-includes/functions.php”

How to use wp_delete_file

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'wp_delete_file', function( $file ) {
	// Change $file here.
	return $file;
}, 10, 1 );

Argument names come from Secure Custom Fields's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

14 plugins that fire wp_delete_file

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Secure Custom Fields icon Secure Custom Fields100,000+ installs apply_filters( 'wp_delete_file', $file ) includes/local-json.php:338
  2. Media Library Organizer icon Media Library Organizer20,000+ installs apply_filters( 'wp_delete_file', $original_file ) includes/global/class-media-library-organizer-replace.php:110
  3. Replace Image icon Replace Image8,000+ installs apply_filters( 'wp_delete_file', $thumbfile ) hm-replace-image.php:124
  4. RSFirewall! icon RSFirewall!4,000+ installs apply_filters( 'wp_delete_file', $file ) models/configuration.php:152
  5. OPML Importer icon OPML Importer3,000+ installs do_action( 'wp_delete_file', $opml_url ) opml-importer.php:182
  6. Avatar Privacy icon Avatar Privacy1,000+ installs apply_filters( 'wp_delete_file', $file ) includes/avatar-privacy/tools/functions.php:45
  7. PicDefense.io icon PicDefense.io100+ installs apply_filters( 'wp_delete_file', $thumbfile ) picdefense.php:174
  8. FastMigrate icon FastMigrate80+ installs apply_filters( 'wp_delete_file', $file ) fast-migrate-server-to-server.php:164
  9. Private Media icon Private Media40+ installs apply_filters( 'wp_delete_file', $thumbfile ) inc/class-private-media-attachment-manager.php:236
  10. Rotating Header icon Rotating Header10+ installs apply_filters( 'wp_delete_file', $medium ) rotating_header.php:496
  11. Profile CCT icon Profile CCT10+ installs apply_filters( 'wp_delete_file', $medium ) views/fields/picture.php:566
  12. Admin User Search icon Admin User Search10+ installs apply_filters( 'wp_delete_file', $exist_cache_location ) admin/class-admin-user-search-admin.php:234
  13. WG Responsive Slider icon WG Responsive SliderFewer than 10 installs apply_filters( 'wp_delete_file', $file ) class.wgrs.slider.php:369
  14. Asciify icon AsciifyFewer than 10 installs apply_filters( 'wp_delete_file', $filename ) asciify.php:212
  15. PageFerry icon PageFerryFewer than 10 installs apply_filters( 'wp_delete_file', $path ) includes/class-pageferry-filesystem.php:152

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.