rest_allow_anonymous_comments
云策文档标注
概述
rest_allow_anonymous_comments 是一个 WordPress 过滤器,用于控制是否允许通过 REST API 创建匿名评论。它影响 WP_REST_Comments_Controller 中的权限检查。
关键要点
- 过滤器名称:rest_allow_anonymous_comments
- 功能:允许或禁止未认证用户通过 REST API 创建评论
- 默认值:false(不允许匿名评论)
- 参数:$allow_anonymous(布尔值,是否允许匿名评论),$request(WP_REST_Request 对象)
- 相关函数:WP_REST_Comments_Controller::create_item_permissions_check()
- 引入版本:4.7.0
代码示例
$allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
原文内容
Filters whether comments can be created via the REST API without authentication.
Description
Enables creating comments for anonymous users.
Parameters
$allow_anonymousbool-
Whether to allow anonymous comments to be created. Default
false. $requestWP_REST_Request-
Request used to generate the response.
Source
$allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |