add_{$meta_type}_meta
Action HookDescription
Fires immediately before meta of a specific type is added. 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). Possible hook names include: - `add_post_meta` - `add_comment_meta` - `add_term_meta` - `add_user_meta`Hook Information
File Location |
wp-includes/meta.php
View on GitHub
|
Hook Type | Action |
Line Number | 123 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$object_id
|
ID of the object metadata is for. |
string
|
$meta_key
|
Metadata key. |
mixed
|
$_meta_value
|
Metadata value. |
Usage Examples
Basic Usage
<?php
// Hook into add_{$meta_type}_meta
add_action('add_{$meta_type}_meta', 'my_custom_function', 10, 3);
function my_custom_function($object_id, $meta_key, $_meta_value) {
// Your custom code here
}
Source Code Context
wp-includes/meta.php:123
- How this hook is used in WordPress core
<?php
118 *
119 * @param int $object_id ID of the object metadata is for.
120 * @param string $meta_key Metadata key.
121 * @param mixed $_meta_value Metadata value.
122 */
123 do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value );
124
125 $result = $wpdb->insert(
126 $table,
127 array(
128 $column => $object_id,
PHP Documentation
<?php
/**
* Fires immediately before meta of a specific type is added.
*
* 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).
*
* Possible hook names include:
*
* - `add_post_meta`
* - `add_comment_meta`
* - `add_term_meta`
* - `add_user_meta`
*
* @since 3.1.0
*
* @param int $object_id ID of the object metadata is for.
* @param string $meta_key Metadata key.
* @param mixed $_meta_value Metadata value.
*/
Quick Info
- Hook Type: Action
- Parameters: 3
- File: wp-includes/meta.php
Related Hooks
Related hooks will be displayed here in future updates.