Removing the email field from the comment form in WordPress just needs a few lines of code in your functions.php of your Theme.

functions.php of your Theme
copy & paste
Advanced Comment Form > Remove email field

How it looks like

comment form with and without email field

Comment Form with and without email field

How to remove the email field with code

1. Disable required email

WordPress has a setting to make the email required for comments. So before removing the email field from the form you should disable this setting first:

You can find it unter Settings > Discussion > Other Comment Settings:

setting for email requirement in WordPressAs you can see, this option does not only make the email address required but also the name. Disable this option first before going on to hide the email field from the frontend.

For quick starters you can now jump right to step 4. If the snippet doesn’t work, go back to square two.

2. Check your theme for a comments.php file

If there is no comments.php file in your theme’s folder, please check the solution below.

3. Check for the comment_form() function

If your theme does have a comments.php file, search for <?php comment_form(); ?> there. If not, you might find it in some other file. It might also be called using some arguments, but if you can’t find it at all, check the solution for missing comment_form() below.

4. Insert this code in your functions.php

If number 1 and 2 didn’t make any problems, simple insert the following lines into the functions.php file of your theme.

I recommend changing the “my_” prefic (as seen twice in the code snippet) to something that makes sense for your project or theme. e.g. wpcomments_remove_email_field_from_comment_form

4. Test

Potential issues / other solutions

Missing comments.php

If your comments.php file is missing and your theme doesn’t have some substitute, simply copy the file from /wp-includes/theme-compat/comments.php into your theme’s directory.

After doing so search the file (in your theme’s directory) for the input field for the website. In WP 3.9.1 it looks like this:

You can remove the whole code and should be done.

Missing call to comment_form();

If you can’t find a call to comment_form() in your theme files, you might check them for some manually coded comment form. Even when customizing comment forms a lot, developers need to send them to the correct url. So search your theme for a call to /wp-comments-post.php, like in the following line to find the form where the comment is send with.

<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>"

If you did find the form, search for an input field for the email, similar to this one and remove all code that corresponds to it.

<input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" />

hide the email field with CSS

If you are not able to hide the email field with the standard WordPress filter or the customizations from above, you might want to hide it. For the standard class of the email input field you can use this code:

This does technically still allow the commenter to enter and submit his email, but most visitors are probably not advanced enough to do so.

Coding insights

The filter used in the code example is defined in function  comment_form()  in the file  /wp-includes/comment-template.php

comment_form() was introduced in WordPress 3.0.0.

About The Author


    1. Thomas Maier Article Author

      Do I understand correctly and you want to hide your email address if you comment on another site? On all sites I know, the email address is not published. If you want to hide your email address to the site admin as well then just create a new one. I personally think it is only fair to give a real email address, but that is up to you.

  1. Nikita

    Hey 😀

    I use wp-discuz for comments. I want to make name mandatory, email optional and remove URL. How can it be done while retaining the same plugin usage?

    1. Thomas Maier Article Author

      Sorry, I don’t know if my plugin is compatible with wp-discuz. You might want to reach out to them.

  2. salman ansari

    i tried to search in my comment.php but that code is not like that you said above.
    i removed the email option but when posting comment it gives error says ’email,name is required ‘
    is there anything else we can do to remove email field ?

    1. Thomas Maier Article Author

      Thank you. It looks like that WordPress code changed. I will investigate it in the new few days.

    2. Thomas Maier Article Author

      Just saw that all is fine. There should be a link to the comment options in _Settings > Discussion_. You’d need to disable the _Comment author must fill out name and email_ option there first.

  3. Vins

    Hi Thomas,

    Nice share, this will definitely increase the number of active users of a blog when applied. There are people who doesn’t feel sharing their email address to just some random blogs because they’re afraid of getting a bunch of emails later on.

  4. Mark Cherkowski

    We have been building WordPress sites for years now and we still fine little things like this to solve issues that we have been fighting with. Thanks!

  5. Synova Care

    It is an excellent idea to use Comment Form with and without email field. This will attract those visitors who don’t want to share their email ID.

  6. laundriz

    No one likes spam or promotional mail in the inbox. Therefore most of the visitors don’t comment due to the email field as they feel that blogger sale their email ID to AD agencies. But removing email field from form make them comfortable to express their feeling in the way of comment.

Leave a Reply

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