How to disable the storage of users IP-address in comment on the WordPress website

One of my friends asked me a question, whether it is possible to disable the storage of the IP-addresses of users who have left comments in WordPress. Some site owners can take this step in order to maintain the privacy of its users. In this article I will show you how you can disable the storage of the IP-addresses in WordPress blog or website.

Advantages and disadvantages of not storing IP-addresses in the comments

By default, WordPress stores the IP-addresses of users who have left a comment on the site. These IP-addresses are stored in a database on a regular basis.

One reason for saving the IP-addresses with each comment: Helping website owners to deal with unwanted comments or spam. Plug-ins, such as by Akismet, can block comments from IP-addresses that are exploited by hackers.

If your users do not use the VPN-services, their real IP-addresses can be found in the logs of your site. Most WordPress hosting providers give access to log file of all the visitors of your site over time.

On the other hand, giving up storage IP-addresses, together with WordPress comment, you can enhance the privacy of your commentators. They will be able to dare to express their views, knowing that your site does not store their IP-addresses.

Method 1: Do not store IP-addresses using the plug-in

This method is the simplest and recommended for beginners. You will need to install the plug-in the Remove the IP. After activating the plug-in, it will change the user’s IP to 127.0.0.1 – address used for the localhost.
The plugin will not delete the IP-addresses that are stored together with the old comments. If you want to delete the data, including old IP-address, read below. We’ll show you how to do it.

Method 2: Do not store IP-addresses manually.

If you are “friends” with the WordPress code, this method will suit you perfectly.
Just paste the following code in your theme’s functions.php:

This is the same code that a plug-in, noted above. However, instead of setting 127.0.0.1 we just cleaned the IP-address.

Remove the IP-addresses of the older comments

Regardless of which method you use to cancel the storage of IP-addresses in the comments, you will still be having old comments containing IP-addresses of your visitors.

Removing the IP-addresses of these comments can be quite simple. To do this, you will need to perform MySQL-specific query to the WordPress database. Prior to this, be sure to make a backup of the database, to make sure we do not break it.

Go to Control Panel and open phpMyAdmin. Select the desired database by clicking on its name in the left column. Next, click on the SQL menu.

remove-ip-from-mysql

You will see a text area, where you will need to enter the query:

Click the Go button under the text area to complete the request and you are done. All IP-addresses of visitors in the comments will be removed from the database.

Note: If your database has a different prefix other than the WordPress, in this case, adjust the SQL-query.