Family Encyclopedia >> Electronics

How to allow users to post anonymous comments in WordPress

Recently, one of our users asked if it was possible to allow anonymous comments 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 the name and email fields of the WordPress comment form.

Pseudonym:The ideal solution

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

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

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

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

Make name and email optional

The next layer of anonymity you can add is to make the name and email field completely optional. No nicknames or anything. If a user submits only one comment without name and email, it will be done. Let's see how to make the name and email fields completely optional.

The first thing you should do is go to Settings »Discussion and uncheck the box next to 'Comment author must fill in name and email' option. Now you need to save your changes and your site will be ready to accept comments without a name or email address.

How to allow users to post anonymous comments in WordPress

Simply removing this checkbox would not tell users that they can leave comments without providing a name or email address. You may want to communicate this by showing that the 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 into your theme's functions.php file or a site-specific plugin.

 función wpb_alter_comment_form_fields ($ fields) // Modificar campo de nombre y muestra que es opcional $ fields ['author'] = '

'. ''. __( 'Nombre: (Opcional)' ) . ''. ($ req? '*': "). '

'; // Modificar el campo de correo electrónico y mostrar que son campos $ opcionales ['email'] = '

'. __ ('Correo electrónico (opcional)', 'veinte y trece'). ''. ($ req? '*': "). '

'; // Esta línea elimina la URL del sitio web del formulario de comentarios. $ fields ['url'] = "; return $ fields; add_filter ('comment_form_default_fields', 'wpb_alter_comment_form_fields');

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

How to allow users to post anonymous comments in WordPress

How to completely remove the name and email from the comment form

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

 función wpb_alter_comment_form_fields ($ fields) unset ($ fields ['author']); unset ($ fields ['email']); unset ($ fields ['url']); devuelve $ campos; add_filter ('comment_form_default_fields', 'wpb_alter_comment_form_fields'); 

If your comment form is displaying your email address will not be published text, then you can hide it by editing your theme's comments.php file. Locate the tag and replace it with this code:

 '

'. __ ('No se requiere nombre ni dirección de correo electrónico'). ($ req? $ required_text: "). '

')); ?>

If you can't locate the comment_form , then you can still hide this text by adding this CSS in your theme or child theme style.css proceedings.

 .comentario-notas mostrar: ninguno; 

This is what your comment form will look like without the name, email, and website URL fields:

How to allow users to post anonymous comments in WordPress

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 Akismet and Sucuri can block some bad IPs, we strongly recommend that you put a captcha check to prevent some of that.

We hope this article has helped you with your decision to allow anonymous comments in WordPress. We cover many comment styles, so if you'd like to learn more, check out our guide on designing your comment layout.

If you like this article, follow us on Google+ and YouTube.