Anonymize IP address of WordPress comments

In the context of the European privacy policy regulations some regulations for web page owners are to be considered. This includes, among other things, the anonymization of the IP address of commentators. Because according to privacy policy regulations, the IP address is a personal data.

What can I do to stop storing the IP address?

By default, the IP address is stored for each comment in the WordPress database. This is not permitted according to the European privacy policy regulations!

Fortunately, this issue can be easily solved. By using the WordPress filter pre_comment_user_ip we can overwrite the IP address and preventing future storage. Just add the following code snippet, for example, to your theme’s functions.php file:

The value “” is just a placeholder. Normally you would see the correct IP address of the commentator here. The value could simply be empty, such as return ''; In this case, you will see the zeroed or no IP address below the comments inside the WordPress backend.