wordpress允许投稿_如何允许用户在WordPress中发布匿名评论
发布日期:2021-09-25 18:43:40 浏览次数:2 分类:技术文章

本文共 5743 字,大约阅读时间需要 19 分钟。

wordpress允许投稿

Recently one of our users asked if it was possible to allow anonymous in WordPress. By default, users cannot leave comments in WordPress without providing a name and email address in the comment form. In this article, we will show you how to allow users to post anonymous comments in WordPress. We will also show you how to hide name and email fields from WordPress comment form.

最近,我们的一位用户询问是否可以在WordPress中允许匿名 。 默认情况下,如果用户未在评论表单中提供姓名和电子邮件地址,则无法在WordPress中留下评论。 在本文中,我们将向您展示如何允许用户在WordPress中发布匿名评论。 我们还将向您展示如何从WordPress评论表单中隐藏名称和电子邮件字段。

别名:理想的解决方案 (Pseudonym: The Ideal Solution)

The best way to allow anonymous comments in WordPress while limiting comment spam is by encouraging users to use a pseudonym or a nickname instead of their real name.

在限制评论垃圾邮件的同时,允许WordPress中匿名评论的最佳方法是鼓励用户使用化名或昵称代替真实姓名。

This allows you to build a community while still allowing users to be anonymous. Users will still have to provide an email address, but most folks who want to leave anonymous comments have separate emails for this anyways.

这使您可以建立社区,同时仍然允许用户匿名。 用户仍然必须提供一个电子邮件地址,但是无论如何,大多数想留下匿名评论的人都有单独的电子邮件。

You can communicate this in your comments policy and place a prominent link to it above your comment form.

您可以在评论政策中进行交流,并在评论表格上方放置醒目链接。

While this is the ideal solution, and the only one that we recommend, there are other solutions to allow further anonymity. However the more anonymity you add, the higher your spam will be.

虽然这是理想的解决方案,也是我们推荐的唯一解决方案,但还有其他解决方案可以允许进一步匿名。 但是,添加的匿名性越高,垃圾邮件的数量就越高。

将名称和电子邮件设置为可选 (Making Name and Email Optional)

The next layer of anonymity you can add is make the name and email field completely optional. No nicknames or anything. If a user submits just a comment without name and email, it will go through. Let’s take a look at how to make name and email fields completely optional.

您可以添加的下一层匿名性是使名称和电子邮件字段完全可选。 没有昵称或其他任何内容。 如果用户仅提交不带名称和电子邮件的评论,它将通过。 让我们看一下如何使名称和电子邮件字段完全可选。

First thing you need to do is go to Settings » Discussion and uncheck the box next to ‘Comment author must fill out name and e-mail’ option. Now you need to save your changes, and your site will be ready to accept comments without name and email address.

您需要做的第一件事是转到“设置”»“讨论”,然后取消选中“评论作者必须填写姓名和电子邮件”选项旁边的框。 现在,您需要保存所做的更改,您的站点将准备好接受没有名称和电子邮件地址的评论。

Disable name and email address as required fields in WordPress comment form

Simply removing this checkbox wouldn’t tell your users that they can leave comments without providing a name or email address. You may want to communicate this by showing that name and email fields are optional. We also suggest removing the website URL field to discourage spam. To do this, you need to modify your comment form. Simply copy and paste the following code in your theme’s file or in a .

简单地删除此复选框并不会告诉您的用户,他们可以在不提供姓名或电子邮件地址的情况下发表评论。 您可能希望通过显示姓名和电子邮件字段为可选来传达此信息。 我们还建议删除网站URL字段以阻止垃圾邮件。 为此,您需要修改评论表单。 只需将以下代码复制并粘贴到主题的文件或于 。

function wpb_alter_comment_form_fields($fields) {// Modify Name Field and show that it's Optional $fields['author'] = '

' . ' ' . ( $req ? '*' : '' ) .'

';// Modify Email Field and show that it's Optional$fields['email'] = ''; // This line removes the website URL from comment form. $fields['url'] = ''; return $fields;}add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields');

This code simply adds (Optional) next to name and email fields in your comment form. It also removes the website URL field from the comment form. If you want to keep the website URL field, then remove that line of code. Here is how your comment form would look like:

该代码只需在您的评论表单中的名称和电子邮件字段旁边添加(可选) 。 它还会从评论表单中删除网站URL字段。 如果要保留网站URL字段,请删除该行代码。 您的评论表单如下所示:

Comment form showing name and email address as optional fields in WordPress

如何从评论表中完全删除姓名和电子邮件 (How to Completely Remove Name and Email From Comment Form)

For those users who want to remove name and email fields from comment form, here is the little piece of code that you need to paste in your theme’s functions.php file or a site specific plugin.

对于那些想要从评论表单中删除姓名和电子邮件字段的用户,这是您需要粘贴在主题的functions.php文件或特定于站点的插件中的一小段代码。

function wpb_alter_comment_form_fields($fields) {    unset($fields['author']);    unset($fields['email']);    unset($fields['url']);    return $fields;}add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields');

If your comment form is showing Your email address will not be published text, then you can hide it by editing the your theme’s comments.php file. Locate the tag <?php comment_form ?> and replace it with this code:

如果您的评论表单显示您的电子邮件地址不会被发布 ,那么您可以通过编辑主题的comment.php文件来隐藏它。 找到标记<?php comment_form ?>并将其替换为以下代码:

'

' . __( 'No name or email address required.' ) . ( $req ? $required_text : '' ) . '

' ));?>

If you can not locate the comment_form, then you can still hide this text by adding this CSS into your theme or ‘s style.css file.

如果无法找到comment_form ,则仍可以通过将CSS添加到主题或的style.css文件中来隐藏此文本。

.comment-notes {display:none;}

This is how your comment form will look like without name, email, and website url fields:

没有名称,电子邮件和网站url字段的情况下,您的评论表单如下所示:

Comment form without name, email and URL fields

关于匿名评论的警告语 (Word of Caution about Anonymous Comments)

Please note that without name and email address as required fields, your comment form will attract a significantly high number of spam comments. While and may block some bad IPs, we highly recommend that you put a to prevent some of that.

请注意,如果没有姓名和电子邮件地址作为必填字段,您的评论表单将吸引大量垃圾邮件评论。 虽然和可能会阻止某些错误的IP,但我们强烈建议您进行以防止某些情况。

We hope this article helped you with your decision of allowing anonymous comments in WordPress. We covered a lot of comment form styling, so if you want to learn more, then check out our guide on .

我们希望本文对您在WordPress中允许匿名评论的决定有所帮助。 我们介绍了很多评论表单样式,因此,如果您想了解更多信息,请查阅我们的指南。

If you like this article, then please follow us on and .

如果您喜欢这篇文章,请在和上关注我们。

翻译自:

wordpress允许投稿

转载地址:https://blog.csdn.net/cumyupx7788305/article/details/108613348 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:wordpress获取封面_如何在WordPress中获取待审帖子的电子邮件通知
下一篇:wordpress远程附件_如何在WordPress中将帖子附件添加为特色图片

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年03月28日 04时34分08秒