# Remove the Email Field From Comments

> Lets visitors comment with just a name, for communities where asking for an email address puts people off.

- Type: PHP
- Runs: Run everywhere
- Category: [Comments](https://wpide.com/library/category/comments/)
- Tags: comments, form, privacy
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/remove-comment-email-field/

## Code

```php
add_filter( 'comment_form_default_fields', function ( $fields ) {
    unset( $fields['email'] );

    return $fields;
} );

// WordPress would otherwise insist on both name and email.
add_filter( 'pre_option_require_name_email', function () {
    return '0';
} );

add_filter( 'preprocess_comment', function ( $commentdata ) {
    $type = isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '';

    if ( ! is_user_logged_in() && ( '' === $type || 'comment' === $type ) && '' === trim( (string) $commentdata['comment_author'] ) ) {
        wp_die( 'Please enter your name.', 'Name required', array( 'response' => 400, 'back_link' => true ) );
    }

    return $commentdata;
} );
```

## Notes

Without email addresses, Gravatars, reply notifications and some spam filters work less well.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove the Email Field From Comments" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
