update_<meta_type>_metadata
Filters whether to update metadata of a specific type.
Description
apply_filters( 'update_<meta_type>_metadata', (null) $null, (int) $object_id, (string) $meta_key, (mixed) $meta_value, (mixed) $prev_value );
The dynamic portion(s) of the hook refer to the meta object type (comment, post, or user). Returning a non-null value will effectively short-circuit the function.
Parameters (5)
- 0. $null (null) =>
null
- Whether to allow updating metadata for the given type.
- 1. $object_id (int)
- The object id.
- 2. $meta_key (string)
- The meta key.
- 3. $meta_value (mixed)
- Meta value. Must be serializable if non-scalar.
- 4. $prev_value — Optional. (mixed)
- If specified, only update existing metadata entries with the specified value. Otherwise, update all entries.
Usage
- To run the hook, copy the example below.
- $null = apply_filters( 'update_{$meta_type}_metadata', $null, $object_id, $meta_key, $meta_value, $prev_value );
- if ( !empty( $null ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the update_<meta_type>_metadata callback
- function filter_update_meta_type_metadata( $null, $object_id, $meta_key, $meta_value, $prev_value ) {
- // make filter magic happen here...
- return $null;
- };
- // add the filter
- add_filter( "update_{$meta_type}_metadata", 'filter_update_meta_type_metadata', 10, 5 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( "update_{$meta_type}_metadata", 'filter_update_meta_type_metadata', 10, 5 );
Defined (1)
The filter is defined in the following location(s).
- /wp-includes/meta.php
- $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );