delete_(meta_type)_metadata filter-hookWP 3.1.0

Short-circuits deleting metadata of a specific type.

The dynamic portion of the hook name, $meta_type, refers to the meta object type (post, comment, term, user, or any other type with an associated meta table). Returning a non-null value will effectively short-circuit the function.

Possible hook names include:

Usage

add_filter( 'delete_(meta_type)_metadata', 'wp_kama_delete_meta_type_metadata_filter', 10, 5 );

/**
 * Function for `delete_(meta_type)_metadata` filter-hook.
 * 
 * @param null|bool $delete     Whether to allow metadata deletion of the given type.
 * @param int       $object_id  ID of the object metadata is for.
 * @param string    $meta_key   Metadata key.
 * @param mixed     $meta_value Metadata value. Must be serializable if non-scalar.
 * @param bool      $delete_all Whether to delete the matching metadata entries for all objects, ignoring the specified $object_id.
 *
 * @return null|bool
 */
function wp_kama_delete_meta_type_metadata_filter( $delete, $object_id, $meta_key, $meta_value, $delete_all ){

	// filter...
	return $delete;
}
$delete(null|true|false)
Whether to allow metadata deletion of the given type.
$object_id(int)
ID of the object metadata is for.
$meta_key(string)
Metadata key.
$meta_value(mixed)
Metadata value. Must be serializable if non-scalar.
$delete_all(true|false)
Whether to delete the matching metadata entries for all objects, ignoring the specified $object_id.
Default: false

Changelog

Since 3.1.0 Introduced.

Where the hook is called

delete_metadata()
delete_(meta_type)_metadata
wp-includes/meta.php 428
$check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );

Where the hook is used in WordPress

wp-includes/default-filters.php 133
add_filter( 'delete_term_metadata', 'wp_check_term_meta_support_prefilter' );
wp-includes/ms-default-filters.php 64
add_filter( 'delete_blog_metadata', 'wp_check_site_meta_support_prefilter' );