auth_(object_type)_meta_(meta_key)_for_(object_subtype) хук-фильтрWP 4.9.8

Filters whether the user is allowed to edit a specific meta key of a specific object type and subtype.

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


add_filter( 'auth_(object_type)_meta_(meta_key)_for_(object_subtype)', 'wp_kama_auth_object_type_meta_key_for_subtype_filter', 10, 6 );

 * Function for `auth_(object_type)_meta_(meta_key)_for_(object_subtype)` filter-hook.
 * @param bool     $allowed   Whether the user can add the object meta.
 * @param string   $meta_key  The meta key.
 * @param int      $object_id Object ID.
 * @param int      $user_id   User ID.
 * @param string   $cap       Capability name.
 * @param string[] $caps      Array of the user's capabilities.
 * @return bool
function wp_kama_auth_object_type_meta_key_for_subtype_filter( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ){

	// filter...
	return $allowed;
Whether the user can add the object meta.
По умолчанию: false
The meta key.
Object ID.
User ID.
Capability name.
Array of the user's capabilities.

Список изменений

С версии 4.9.8 Введена.

Где вызывается хук

wp-includes/capabilities.php 488
$allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps );

Где используется хук в WordPress

wp-includes/meta.php 1499
add_filter( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['auth_callback'], 10, 6 );
wp-includes/meta.php 1644
remove_filter( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['auth_callback'] );