钩子文档

auth_post_meta_{$meta_key}

💡 云策文档标注

概述

auth_post_meta_{$meta_key} 是一个动态过滤器钩子,用于控制用户是否被允许向文章添加特定元数据。它基于 meta_key 进行动态命名,并涉及权限检查。

关键要点

  • 这是一个动态钩子,名称中的 $meta_key 部分由传递给 map_meta_cap() 的元键决定。
  • 用于过滤用户添加文章元数据的权限,默认情况下不允许(false)。
  • 参数包括 $allowed(布尔值,默认 false)、$meta_key(字符串)、$post_id(整数)、$user_id(整数)、$cap(字符串)和 $caps(数组)。
  • 自 WordPress 3.3.0 版本引入。

📄 原文内容

Filters whether the user is allowed to add post meta to a post.

Description

The dynamic portion of the hook name, $meta_key, refers to the meta key passed to map_meta_cap() .

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

// The user is trying to edit someone else's post.

Changelog

Version Description
3.3.0 Introduced.