wordpress - 如何在woocommerce中限制每个产品的一次评论
问题描述
嗨,我想将一条评论限制为来自经过验证的买家的一种产品,
我在几个论坛上搜索过,但到目前为止我还没有成功
我从另一个论坛找到了这段代码
// Check if user has previously commented the post.
global $current_user, $post;
if ( ! is_user_logged_in() ) {
// Show the comment form if the user is not logged in.
comment_form();
} else { // The user is logged in...
// Get the comments for the logged in user.
$usercomment = get_comments( array (
'user_id' => $current_user->ID,
'post_id' => $post->ID,
) );
// If the user has commented, output a message.
if ( $usercomment ) {
echo '<p>Vous avez déjà signé cette pétition. S\'il vous plaît partager avec votre famille et vos amis</p>';
} else { // Otherwise, show the comment form.
comment_form();
}
}
但我不知道如何自定义single-product-reviews.php模板文件
代码来自这个论坛的答案
https://wordpress.stackexchange.com/a/137814
在哪一行添加代码?
谢谢
解决方案
推荐阅读
- python - 姜戈 | 首次登录时重定向
- javascript - 函数 Javascript 外的 const 变量
- c# - 不要将 XML 文档文件从 NuGet 包复制到 bin
- mongodb - 如何在具有多个状态的集合中获得 mongodb 中的第二高状态
- python - 从 ONNX 运行超分辨率模型时出错
- c# - 如何在 UWP 中获得像 Groove 音乐中的迷你弹出窗口?
- python-3.x - 无法解压不可迭代的 NoneType 对象
- selenium - import selenium from selenium import webdriver driver = webdriver.Chrome("G:\\Web Development learn\\Jarvis\\Chrome\\chromedriver.exe")
- python - Python/Pygame 在离开窗口时使 Pygame 中的文本换行
- elasticsearch - 如何在所有字段中进行搜索并使用弹性搜索中指定的字段进行搜索?