delete_{$meta_type}_meta
Action 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 | Action |
Line Number | 1048 |
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}_meta
add_action('delete_{$meta_type}_meta', 'my_custom_function', 10, 2);
function my_custom_function($delete, $meta_id) {
// Your custom code here
}
Source Code Context
wp-includes/meta.php:1048
- How this hook is used in WordPress core
<?php
1043 $meta = get_metadata_by_mid( $meta_type, $meta_id );
1044 if ( $meta ) {
1045 $object_id = (int) $meta->{$column};
1046
1047 /** This action is documented in wp-includes/meta.php */
1048 do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
1049
1050 // Old-style action.
1051 if ( 'post' === $meta_type || 'comment' === $meta_type ) {
1052 /**
1053 * Fires immediately before deleting post or comment metadata of a specific type.
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: Action
- Parameters: 2
- File: wp-includes/meta.php
Related Hooks
Related hooks will be displayed here in future updates.