auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}
Filter HookDescription
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.Hook Information
| File Location |
wp-includes/capabilities.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 491 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
bool
|
$allowed
|
Whether the user can add the object meta. Default false. |
string
|
$meta_key
|
The meta key. |
int
|
$object_id
|
Object ID. |
int
|
$user_id
|
User ID. |
string
|
$cap
|
Capability name. |
string[]
|
$caps
|
Array of the user's capabilities. |
Usage Examples
Basic Usage
<?php
// Hook into auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}
add_filter('auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}', 'my_custom_filter', 10, 6);
function my_custom_filter($allowed, $meta_key, $object_id, $user_id, $cap, $caps) {
// Your custom filtering logic here
return $allowed;
}
Source Code Context
wp-includes/capabilities.php:491
- How this hook is used in WordPress core
<?php
486 * @param int $object_id Object ID.
487 * @param int $user_id User ID.
488 * @param string $cap Capability name.
489 * @param string[] $caps Array of the user's capabilities.
490 */
491 $allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps );
492 } else {
493
494 /**
495 * Filters whether the user is allowed to edit a specific meta key of a specific object type.
496 *
PHP Documentation
<?php
/**
* 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.
*
* @since 4.9.8
*
* @param bool $allowed Whether the user can add the object meta. Default false.
* @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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 6
- File: wp-includes/capabilities.php
Related Hooks
Related hooks will be displayed here in future updates.