# Remove IP Addresses From Comment Notification Emails

> Strips commenters' IP addresses and host names from the new comment and moderation emails WordPress sends to authors and administrators, so personal data does not pile up in inboxes.

- Type: PHP
- Runs: Run everywhere
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: comments, email, ip-address
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-no-ip-in-comment-emails/

## Code

```php
$wpide_strip_comment_ip = function ( $message, $comment_id ) {
    $comment = get_comment( $comment_id );

    if ( ! $comment ) {
        return $message;
    }

    // English wording first, then any remaining copy of the raw address (for translated emails).
    $message = preg_replace( '/\s*\(IP address: [^)]*\)/', '', $message );

    if ( $comment->comment_author_IP ) {
        $message = str_replace( $comment->comment_author_IP, '[hidden]', $message );
    }

    return $message;
};

add_filter( 'comment_notification_text', $wpide_strip_comment_ip, 20, 2 );
add_filter( 'comment_moderation_text', $wpide_strip_comment_ip, 20, 2 );
```

## Notes

The IP address is still visible in the dashboard for administrators if you store it.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove IP Addresses From Comment Notification Emails" 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/
