# Store Shortened IP Addresses for Contact Form 7 Submissions

> Shortens the visitor IP address that Contact Form 7 records with each submission (used in mail tags and by Flamingo and spam filters), so a full address is never kept.

- Type: PHP
- Runs: Run everywhere
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: contact-form-7, ip-address, gdpr
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-cf7-mask-ip/

## Code

```php
add_filter( 'wpcf7_remote_ip_addr', function ( $ip ) {
    return $ip ? wp_privacy_anonymize_ip( $ip ) : $ip;
} );
```

## Notes

Return an empty string instead to drop the IP address entirely; spam protection that relies on it may become less accurate.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Store Shortened IP Addresses for Contact Form 7 Submissions" 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/
