钩子文档

override_post_lock

💡 云策文档标注

概述

override_post_lock 是一个 WordPress 过滤器,用于控制是否允许覆盖文章锁定。默认情况下允许覆盖,但通过此过滤器可以禁用此功能。

关键要点

  • 过滤器名称:override_post_lock
  • 作用:决定是否允许用户覆盖其他用户对文章的锁定
  • 默认值:true(允许覆盖)
  • 参数:$override(布尔值,是否允许覆盖)、$post(WP_Post 对象,文章对象)、$user(WP_User 对象,锁定文章的用户)
  • 返回值:返回 false 将禁用覆盖文章锁定的能力
  • 引入版本:WordPress 3.6.0

代码示例

$override = apply_filters( 'override_post_lock', true, $post, $user );

注意事项

  • 此过滤器在 _admin_notice_post_locked() 函数中使用,用于显示文章被锁定的通知
  • 开发者可以通过添加过滤器回调来修改覆盖行为,例如基于用户角色或文章状态

📄 原文内容

Filters whether to allow the post lock to be overridden.

Description

Returning false from the filter will disable the ability to override the post lock.

Parameters

$overridebool
Whether to allow the post lock to be overridden. Default true.
$postWP_Post
Post object.
$userWP_User
The user with the lock for the post.

Source

$override = apply_filters( 'override_post_lock', true, $post, $user );

Changelog

Version Description
3.6.0 Introduced.