Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Allow Users to Post Anonymous Comments in WordPress

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Do you want to allow users to post anonymous comments in WordPress?

By default, users cannot leave comments in WordPress without providing a name and email address in the comment form. However, not every visitor wants to share their personal data.

In this article, we will show you how to allow users to post anonymous comments on your WordPress website. We will also show you how to hide name and email fields from WordPress comment form.

How to allow users to post anonymous comments in WordPress

Should You Allow Anonymous Comments in WordPress?

Comments allow visitors to leave feedback and suggestions that can help improve your WordPress website.

Blog readers can also use comments to engage with other users. A lively comment section can create a sense of community around your WordPress blog. Some people may even return to a post just to read new comments, which means more pageviews for your site.

The problem is that WordPress does not allow users to leave a comment without sharing their name and email address, and some users are simply more privacy conscious.

They may not always feel comfortable leaving a comment under their real name.

In this case, the most ideal solution is to encourage 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 by adding a comments policy right above your comment form.

However sometimes, you may want to allow further anonymity by either making the name and email optional, or entirely removing the name and email field from your comment form.

Just be aware that allowing anonymous comments can make your site more vulnerable to comment spam. If you do allow users to post anonymous comments, then you should also use tools to combat comment spam. You can also see our guide on how to moderate comments in WordPress for more tips.

With that in mind, let’s see how you can allow users to post anonymous comments in WordPress. If you prefer to jump straight to a particular method, then you can go ahead and use the links below.

Method 1. Allow Users to Post Anonymously With Optional Name and Email fields

The standard WordPress comment form asks the user to type in an email address and name before they can post a comment.

These fields are required by default, but you can make them optional. This means that visitors who feel comfortable sharing their personal information still have a way to enter their name and email address.

To make the comment form’s ‘Name’ and ‘Email’ fields optional, go to Settings » Discussion in your WordPress dashboard.

Here, simply uncheck the box next to ‘Comment author must fill out name and email.’

Allow anonymous comments in WordPress

Once you’ve done that, just scroll to the bottom of the page and click on Save Changes.

Visitors can now comment without typing in their name and email address. However, the standard WordPress comment form still shows the ‘Name’ and ‘Email’ fields as required, so visitors won’t know that they can post anonymously.

With that in mind, you’ll want to add ‘Optional’ labels to the ‘Name’ and ‘Email’ fields. While you’re making this change, we also suggest removing the website URL field from the WordPress comment form.

Many spammers and bots post comments with the goal of placing a link on your website. By removing the website URL field from your WordPress comment form, you can discourage people from posting spam comments.

You can add the ‘Optional’ labels and hide the website URL field by adding the following code snippet to your website.

You can either add this code to your functions.php file, in a site-specific plugin, or by using a code snippets 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');

Then, simply save your changes.

If you visit your site, you’ll now see that the ‘Name’ and ‘Email’ fields are marked as ‘Optional.’ You’ve also removed the website URL field from the WordPress comment form.

A WordPress comment form

For more details, see our step by step guide on how to style the WordPress comment form.

Method 2. Remove the Name and Email Fields From the WordPress Comment Form

Another option is to completely remove the ‘Name’ and ‘Email’ fields from the WordPress comment form. This makes it very clear that visitors can post anonymously.

To do this, you’ll need to add some code to your theme’s functions.php file. However, if you add this code to the functions.php file directly, then you risk losing your custom code every time you update your WordPress theme.

Instead, we recommend creating a child theme and then adding the code to that child theme. In this way, you can update your theme without losing the code you added to functions.php. To learn more, please see our step by step guide on how to create a WordPress child theme.

Your other options are creating a site-specific plugin, or using a code snippets plugin.

No matter what option you choose, you can completely remove the ‘Name’ and ‘Email’ fields by adding the following code:

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');

Now, if you visit your website, you’ll see that visitors can no longer type in their email address or name.

An anonymous comment form in WordPress

Depending on your WordPress theme, your comment section may still show the following text:

Your email address will not be published. Required fields are marked *

Giving users the option to post anonymous comments in WordPress

Since visitors can no longer type in their email address, this message is confusing. If you remove the ‘Name’ and ‘Email’ fields, then you should also remove this message.

To delete the ‘Your email address will not be published’ line, open your theme’s comments.php file. You can now find the following section:

<?php comment_form ?>

Then, simply replace this section with the following code:

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

Every theme is different, so your theme may not have a <?php comment_form ?> section.

If you can’t find this code, then just open your theme’s style.css file instead.

You can then add the following code snippet, which will remove the ‘Your email address will not be published’ text:

.comment-notes {
display:none;
}

The following image shows how your WordPress comment form will look without this message.

An example of anonymous commenting in WordPress

As you can see in the image above, the WordPress comment form also has a checkbox that says ‘Save my name, email, and website in this browser for the next time I comment.’

This checkbox is an important part of making your site GDPR compliant.

Since you’re not collecting any personally identifiable information from your visitors, then you can remove this checkbox.

To remove the ‘Save my name…’ checkbox, simply add the following code to your functions.php file:

add_filter( 'comment_form_default_fields', 'wpb_comment_form_hide_cookies_consent' );
function wpb_comment_form_hide_cookies_consent( $fields ) {
	unset( $fields['cookies'] );
	return $fields;
}

After saving your changes, you’ll see that the ‘Save my name…’ message has disappeared from your WordPress comment form.

An anonymous WordPress comment form

Some visitors will want to keep their private information private. However, other people may want to share their contact information with you.

If you do delete the ‘Name’ and ‘Email’ fields, then you may want to give visitors a different way to share their personal information.

A contact form lets visitors reach out to you directly and get a personalized response. To learn more, you can see our step by step guide on how to create a contact form in WordPress.

You can also use email capture tools to collect the contact information of potential customers, and keep in touch with the people who visit your website.

We hope this article helped you learn how to allow users to post anonymous comments in WordPress. You can also go through our guide on the best analytics solutions for WordPress users and how to allow user registration on your WordPress site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

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. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

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

24 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Juan Pablo says

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

  3. Chris says

    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.

  4. Ahmad says

    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?

  5. Usana says

    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!

    • WPBeginner Support says

      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

  6. C.K. Matthews says

    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.

WPBeginner Assistant
How can I help you?

By chatting, you consent to this chat being stored according to our privacy policy and your email will be added to receive weekly WordPress tutorials from WPBeginner.