sanitize_<object_type>_meta_<meta_key>

Filters the sanitization of a specific meta key of a specific meta type.

Description

apply_filters( 'sanitize_<object_type>_meta_<meta_key>', (mixed) $meta_value, (string) $meta_key, (string) $object_type ); 

The dynamic portions of the hook name refer and $meta_key,, refer to the metadata object type (comment, post, or user) and the meta key value, respectively.

Parameters (3)

0. $meta_value (mixed)
Meta value to sanitize.
1. $meta_key (string)
The meta key.
2. $object_type (string)
The object type.

Usage

To run the hook, copy the example below.
  1. $meta_value = apply_filters( 'sanitize_{$object_type}_meta_{$meta_key}', $meta_value, $meta_key, $object_type ); 
  2.  
  3. if ( !empty( $meta_value ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the sanitize_<object_type>_meta_<meta_key> callback 
  2. function filter_sanitize_object_type_meta_meta_key( $meta_value, $meta_key, $object_type ) { 
  3. // make filter magic happen here... 
  4. return $meta_value
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "sanitize_{$object_type}_meta_{$meta_key}", 'filter_sanitize_object_type_meta_meta_key', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "sanitize_{$object_type}_meta_{$meta_key}", 'filter_sanitize_object_type_meta_meta_key', 10, 3 ); 

Defined (3)

The filter is defined in the following location(s).

/wp-includes/meta.php  
  1. return apply_filters( "sanitize_{$object_type}_meta_{$meta_key}", $meta_value, $meta_key, $object_type ); 
  1. add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 3 ); 
  1. remove_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'] );