WordPress filter hook

delete_post_metadata

Fired by 5 WordPress plugins, running on 42K+ sites between them.

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

How to use delete_post_metadata

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

functions.php
add_filter( 'delete_post_metadata', function( $value, $id, $key, $arg4, $arg5 ) {
	// Change $value here.
	return $value;
}, 10, 5 );

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

5 plugins that fire delete_post_metadata

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

  1. Image Watermark icon Image Watermark40,000+ installs apply_filters( 'delete_post_metadata', null, $id, $key, '', false ) includes/class-upload-handler.php:11537
  2. SOOZ icon SOOZ2,000+ installs apply_filters( 'delete_post_metadata', null, $attachment_post_id, $meta_key, $rollback_hook_value, false ) includes/core/attachments-media.php:3114
  3. ProRank SEO icon ProRank SEO10+ installs apply_filters( 'delete_post_metadata', null, $id, $key, $expected, false ) includes/Core/Content/PostContentWriter.php:106
  4. PerfLocale icon PerfLocaleFewer than 10 installs apply_filters( 'delete_post_metadata', null, $post_id, $key, '', false ) src/Translation/Fields/PostMetaStorage.php:152
  5. JonnyAD SEO icon JonnyAD SEOFewer than 10 installs apply_filters( 'delete_post_metadata', null, $post_id, $key, $from, false ) includes/admin.php:1430

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.