我试图仅对星级进行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' );
?>
但是我无法删除必填的姓名和电子邮件字段,因此未注册的用户可以输入星级产品评级。
请帮助
这是Wordpress中的一个选项,请转到“设置”>“讨论”,然后查找所需的电子邮件和名称设置。删除复选标记并保存设置页面。