Beginner's Guide for WordPress / Start your WordPress Blog in minutes

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 name and email fields from WordPress comment form.

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.

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 functions.php file or in a site-specific plugin.

function wpb_alter_comment_form_fields($fields) {

// Modify Name Field and show that it's Optional 
$fields['author'] = '<p class="comment-form-author">' . '<label for="author">' . __( 'Name (Optional)' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>';

// Modify Email Field and show that it's Optional
$fields['email'] = '<p class="comment-form-email"><label for="email">' . __( 'Email (Optional)', 'twentythirteen' ) . '</label> ' .
      ( $req ? '<span class="required">*</span>' : '' ) .
      '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) .
      '" size="30"' . $aria_req . ' /></p>'; 

// 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:

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.

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:

<?php 
comment_form(array(
'comment_notes_before' => '<p class="comment-notes">' . __( 'No name or email address required.' ) . ( $req ? $required_text : '' ) . '</p>'
    ));
?>

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

.comment-notes {
display:none;
}

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

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

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 styling your comments layout.

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

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

21 CommentsLeave a Reply

  1. I can’t disable Users must be registered and logged in to comment – dunno why. Any tricks to do it with php function?

  2. So the first option to label the Name and EMail text area as “Optional” did not work. Instead, the Text areas for both Name and EMail are still there but there are no labels next to them, they are blank.

  3. So does links from Twitter activity now count for search
    engine optimisation? I heard they help after the Penguin Google
    algorithm refresh
    Do you participate in any forums?

  4. I don´t know if it was a concidence but about a month ago I did turn off all comments off and my Alexa Ranking went down (same amount of organic visitors)… what do you think? By the way this is my blog url: (Yes… I do post in Spanish).

    Have a great day!

    • We don’t think Alexa Rankings are important, relevant, or an accurate tool. What you need to measure, is how your users react to change. Check how it affects your bounce rate, user engagement, conversions, and other metrics.

      Admin

  5. I’ve created a custom post type that members can use to post questions to forum. In the single-custom-post-type.php I simply omitted the author id tag so the author’s name is anonymous.

    What I want to achieve now is that if the post author wants to ask a question to the commented he or she can do so anonymously. Is there a way to edit or create a custom comment form to do something like if(!author() ) show comment author name?

    I’m very new to this and I have a custom-comments.php but evidentally what I need is in the comment_form () which at this time I am using Jetpack comments.

    Please advise.

Leave a Reply to Kenneth Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.