delete_{$meta_type}_metadata_by_mid
Filter HookDescription
Short-circuits deleting metadata of a specific type by meta ID. 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: - `delete_post_metadata_by_mid` - `delete_comment_metadata_by_mid` - `delete_term_metadata_by_mid` - `delete_user_metadata_by_mid`Hook Information
| File Location |
wp-includes/meta.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 1037 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
null|bool
|
$delete
|
Whether to allow metadata deletion of the given type. |
int
|
$meta_id
|
Meta ID. |
Usage Examples
Basic Usage
<?php
// Hook into delete_{$meta_type}_metadata_by_mid
add_filter('delete_{$meta_type}_metadata_by_mid', 'my_custom_filter', 10, 2);
function my_custom_filter($delete, $meta_id) {
// Your custom filtering logic here
return $delete;
}
Source Code Context
wp-includes/meta.php:1037
- How this hook is used in WordPress core
<?php
1032 * @since 5.0.0
1033 *
1034 * @param null|bool $delete Whether to allow metadata deletion of the given type.
1035 * @param int $meta_id Meta ID.
1036 */
1037 $check = apply_filters( "delete_{$meta_type}_metadata_by_mid", null, $meta_id );
1038 if ( null !== $check ) {
1039 return (bool) $check;
1040 }
1041
1042 // Fetch the meta and go on if it's found.
PHP Documentation
<?php
/**
* Short-circuits deleting metadata of a specific type by meta ID.
*
* 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:
*
* - `delete_post_metadata_by_mid`
* - `delete_comment_metadata_by_mid`
* - `delete_term_metadata_by_mid`
* - `delete_user_metadata_by_mid`
*
* @since 5.0.0
*
* @param null|bool $delete Whether to allow metadata deletion of the given type.
* @param int $meta_id Meta ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/meta.php
Related Hooks
Related hooks will be displayed here in future updates.