Woocommerce产品评级仅含星级

Woocommerce产品评级仅含星级,woocommerce,comments,rating,required-field,Woocommerce,Comments,Rating,Required Field,我正在努力使woocommerce产品评级只与明星。因此,我需要删除当前所需的字段名称、电子邮件和注释 我已经完成了用这段代码删除注释 <?php function rei_preprocess_comment($comment_data) { if ($comment_data['comment_content'] == '%dummy-text%') { $comment_data['comment_content'] = ''; // replace dumm

我正在努力使woocommerce产品评级只与明星。因此,我需要删除当前所需的字段名称、电子邮件和注释

我已经完成了用这段代码删除注释

<?php
function rei_preprocess_comment($comment_data) {
    if ($comment_data['comment_content'] == '%dummy-text%') {
        $comment_data['comment_content'] = ''; // replace dummy text.
    }
    return $comment_data;
}
add_filter('preprocess_comment', 'rei_preprocess_comment');
function rei_wp_footer() {
    ?>
    <script>
    jQuery(function($){
        var comment = $('textarea#comment');
        comment.removeAttr('required'); // remove required attribute of textarea.
        $('#commentform').on('submit',function(){
            if (comment.val() == '') {
                comment.css('text-indent','-999px').val('%dummy-text%'); // change to dummy text.
            }
        });
    });
    </script>
    <?php
}
add_action( 'wp_footer', 'rei_wp_footer' );
?>

jQuery(函数($){
var comment=$('textarea#comment');
comment.removeAttr('required');//删除textarea的required属性。
$('#commentform')。在('submit',function()上{
如果(comment.val()=''){
comment.css('text-indent','-999px').val('%dummy text%');//更改为dummy text。
}
});
});
但是,我无法删除所需的名称和电子邮件字段,以便未注册的用户可以输入星级产品评级


请帮助

这是Wordpress中的一个选项,请转到设置>讨论并查找所需的电子邮件和姓名设置。删除复选标记并保存设置页面。

Thnx,但我需要修改产品评论,而不是发布评论。“设置”>“讨论”中的选项仅用于发表评论。您是对的,它正在处理设置中的更改。原因是Woocomece在评论系统中使用发表评论。每个评论都是带有特殊属性的评论。上面的代码不起作用。当我尝试为一个产品添加第二个评级时,我得到的信息是“你已经说过了”