wordpress - 将 wp 评论显示为拒绝所有用户
问题描述
我希望能够在 wp 的后端“拒绝”评论而不更改或删除评论内容。
在网站的前端,我希望将评论作者姓名列为正常,但评论内容中只有一个简单的声明,上面写着“此评论因违反我们的 TOS 而被拒绝”
我该怎么办?我发现似乎没有插件可以处理此功能。
解决方案
您可以使用下面的代码片段。此代码段将过滤要显示的评论文本。
function filter_text( $comment_text, $comment = null ) {
// Do something to the comment, possibly switching based on the presence of $comment
$comment_text = 'This comment was rejected for violations of our TOS';
return $comment_text;
}
add_filter( 'comment_text', 'filter_text', 10, 2 );
推荐阅读
- java - 在 Java 中使用 Thread.sleep 时如何暂停输入
- php - 包含 php 网站的问题
- javascript - 在函数内增长和缩小的变量的空间复杂度
- python - Python字典到xlsx中的列
- linux - 在linux上的文件夹之间复制文件
- ssl - Rundeck gmail smtp设置
- javascript - React js: ./src/App.js Line 22: 'lastWinner' is not defined no-undef 搜索关键字以了解有关每个错误的更多信息
- javascript - 在 Firebase 中写入数据后读取数据
- c# - Dns.GetHostEntry 在 Xamarin 窗体中不起作用
- reactjs - 无法对未安装的组件执行 React 状态更新?