WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Allow Users to Post Anonymous Comments in WordPress

How to Allow Users to Post Anonymous Comments in WordPress

Last updated on March 31st, 2014 by Editorial Staff
47 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
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.

47 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

21 Comments

Leave a Reply
  1. chinmay says:
    Feb 24, 2021 at 4:09 am

    Thanks for the guidance. This helped me a lot.

    Reply
    • WPBeginner Support says:
      Feb 24, 2021 at 9:33 am

      Glad our guide was helpful :)

      Reply
  2. Kenneth says:
    Sep 30, 2020 at 3:39 pm

    Thank you for this article post. It’s really helpful.

    Reply
    • WPBeginner Support says:
      Oct 1, 2020 at 8:53 am

      Glad our guide was helpful :)

      Reply
  3. Rajesh Kumar says:
    Sep 14, 2020 at 8:35 am

    Will it not lead to a lot of spam comments?

    Reply
    • WPBeginner Support says:
      Sep 15, 2020 at 1:11 pm

      There is a chance but this is for users looking to offer this option.

      Reply
  4. Heather says:
    Oct 21, 2019 at 5:52 am

    so helpful, thank you :-)

    Reply
    • WPBeginner Support says:
      Oct 21, 2019 at 10:40 am

      You’re welcome :)

      Reply
  5. reem says:
    Jul 22, 2019 at 10:21 am

    thanks,for helps

    Reply
    • WPBeginner Support says:
      Jul 22, 2019 at 1:17 pm

      Glad our article could be helpful :)

      Reply
  6. Bahati walker says:
    Dec 12, 2018 at 10:01 am

    Thanks a lot for your guide

    Reply
  7. Juan Pablo says:
    Aug 19, 2018 at 3:06 am

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

    Reply
  8. Chris says:
    Nov 12, 2017 at 9:06 pm

    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.

    Reply
  9. Hina says:
    Mar 3, 2017 at 2:20 pm

    How to Comments in WordPress plugins. Please Help

    Reply
  10. Ahmad says:
    Jan 1, 2017 at 1:37 am

    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?

    Reply
  11. Usana says:
    Aug 31, 2015 at 1:35 pm

    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!

    Reply
    • WPBeginner Support says:
      Sep 2, 2015 at 10:16 am

      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.

      Reply
  12. ajinkya pawar says:
    Aug 17, 2015 at 3:44 am

    How to Comments in WordPress plugins

    Reply
  13. Someone says:
    Jun 22, 2014 at 9:07 am

    HEy im anon!… And my IP address?

    Reply
  14. C.K. Matthews says:
    Apr 25, 2014 at 10:28 am

    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.

    Reply
  15. Coupontray says:
    Mar 31, 2014 at 10:12 am

    Its better to use Disqus to handle Anonymous comments in any platform.

    Reply

Leave a Reply 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.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
TrustPulse
TrustPulse
Instantly get 15% more conversions with social proof. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2021 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2021)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2021)
    • SiteGround Reviews from 4464 Users & Our Experts (2021)
    • Bluehost Review from Real Users + Performance Stats (2021)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2021 – Step by Step Guide
Deals & Coupons (view all)
RingCentral Coupon Code
RingCentral Coupon
Get 34% OFF RingCentral, a popular VoIP and business communications solution.
WP Security Audit Log
WP Security Audit Log Coupon
Get 15% OFF on WP Security Audit Log WordPress activity log plugin.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).

Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
  • Growth Fund
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon
  • AIOSEO

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress Security by Sucuri.