auth_post_{$post_type}_meta_{$meta_key}
云策文档标注
概述
auth_post_{$post_type}_meta_{$meta_key} 是一个 WordPress 过滤器钩子,用于控制用户是否被允许为特定文章类型的文章添加自定义字段(post meta)。该钩子名称包含动态部分 $post_type 和 $meta_key,分别对应文章类型和元键。
关键要点
- 这是一个过滤器钩子,用于检查用户添加文章元数据的权限。
- 钩子名称是动态的,包含 $post_type 和 $meta_key 变量,需根据实际文章类型和元键替换。
- 参数包括 $allowed(布尔值,默认 false)、$meta_key(字符串)、$post_id(整数)、$user_id(整数)、$cap(字符串)和 $caps(数组)。
- 首次引入于 WordPress 4.6.0 版本。
原文内容
Filters whether the user is allowed to add post meta to a post of a given type.
Description
The dynamic portions of the hook name, $meta_key and $post_type, refer to the meta key passed to map_meta_cap() and the post type, respectively.
Parameters
$allowedbool-
Whether the user can add the post meta. Default false.
$meta_keystring-
The meta key.
$post_idint-
Post ID.
$user_idint-
User ID.
$capstring-
Capability name.
$capsarray-
User capabilities.
Source
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |