add_term_metadata filter-hookWP 3.1.0

Short-circuits adding metadata of a specific type.

This is one of the variants of the dynamic hook add_(meta_type)_metadata

Usage

add_filter( 'add_term_metadata', 'wp_kama_add_term_metadata_filter', 10, 5 );

/**
 * Function for `add_term_metadata` filter-hook.
 * 
 * @param null|bool $check      Whether to allow adding metadata for the given type.
 * @param int       $object_id  ID of the object metadata is for.
 * @param string    $meta_key   Metadata key.
 * @param mixed     $meta_value Metadata value. Must be serializable if non-scalar.
 * @param bool      $unique     Whether the specified meta key should be unique for the object.
 *
 * @return null|bool
 */
function wp_kama_add_term_metadata_filter( $check, $object_id, $meta_key, $meta_value, $unique ){

	// filter...
	return $check;
}
$check(null|true|false)
Whether to allow adding metadata for the given type.
$object_id(int)
ID of the object metadata is for.
$meta_key(string)
Metadata key.
$meta_value(mixed)
Metadata value. Must be serializable if non-scalar.
$unique(true|false)
Whether the specified meta key should be unique for the object.

Changelog

Since 3.1.0 Introduced.

Where the hook is called

add_metadata()
add_term_metadata
wp-includes/meta.php 80
$check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );

Where the hook is used in WordPress

wp-includes/default-filters.php 131
add_filter( 'add_term_metadata', 'wp_check_term_meta_support_prefilter' );