WP HOOKS
filtrdynamicznyod 3.1.0

add_{$meta_type}_metadata

Args 5Plik wp-includes/meta.php

Opis — z kodu źródłowego

Short-circuits adding metadata of a specific type.

The dynamic portion of the hook name, $meta_type, refers to the meta object type (blog, 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:

  • add_blog_metadata
  • add_post_metadata
  • add_comment_metadata
  • add_term_metadata
  • add_user_metadata

Hook dynamiczny — możliwe nazwy

add_blog_metadataadd_comment_metadataadd_post_metadataadd_term_metadataadd_user_metadata

Parametry

ParametrTypOpis
$checknull | int | falseWhether to allow adding metadata for the given type. Return false or a meta ID to short-circuit the function. Return null to continue with the default behavior.
$object_idintID of the object metadata is for.
$meta_keystringMetadata key.
$meta_valuemixedMetadata value. Must be serializable if non-scalar.
$uniqueboolWhether the specified meta key should be unique for the object.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'add_{$meta_type}_metadata', 'twoja_funkcja', 10, 5 );

function twoja_funkcja($param_1, $param_2, $param_3, $param_4, $param_5) {
	// Twój kod
}