Family Best Time >> Electronics

How to stop storing IP address in WordPress comments

After reading our article on how to allow anonymous comments, one of our readers asked us if it is possible to stop storing IP address in WordPress comments. Some site owners may want to do this to protect the privacy of their users. In this article, we will show you how to stop storing IP address in WordPress comments.

How to stop storing IP address in WordPress comments

Pros and cons of not storing IP address in WordPress comments

By default, WordPress logs and stores the IP addresses of users who leave comments on your website. These IP addresses are permanently stored in its database.

The reason for storing IP addresses with each comment is to help site owners combat comment spam or spam. Plugins like Akismet can block comments from IP addresses known to spammers.

Unless your users are using a VPN service, their real IP addresses can still be found in your site logs. Most WordPress hosting providers keep an access log of all visitors to their website for a limited period of time.

Moreover, by not storing the IP address in WordPress comments, you can improve the privacy of commenters on your website. They may feel more confident expressing their opinions knowing that your site does not store IP addresses with comments.

Method 1:Stop storing IP addresses in comments with plugin

This method is easier and recommended for new websites and beginners.

The first thing you need to do is install and activate the Remove IP plugin. For more details, check out our step-by-step guide on how to install a WordPress plugin.

Once activated, the plugin will replace the user's IP with 127.0.0.1, which is an IP address normally used by localhost.

The plugin will not delete IP addresses stored with previous comments. If you have previous comments with IP addresses stored with them, then you can delete those IP addresses as well. We'll show you how to do this later in this article.

Method 2:Manually stop saving IP addresses with WordPress comments

If you're comfortable pasting code snippets into WordPress, you should use this method instead.

Simply add this code to your theme's functions.php file or a site-specific plugin.

 función wpb_remove_commentsip ($ comment_author_ip) return "; add_filter ('pre_comment_user_ip', 'wpb_remove_commentsip'); 

This is basically the same code used by the plugin we mentioned in the first method. However, instead of storing 127.0.0.1, it leaves the IP field blank.

Remove IP address from previous comments

Regardless of the method you use to stop comment IP storage, old comments on your WordPress site will always have IP addresses stored with them.

If you have old comments on your site, you may want to remove the IP addresses from those comments.

We'll show you how to do this by running a MySQL query against your WordPress database. It is very important to make sure you have the latest WordPress database backup.

Next, you need to login to your WordPress hosting control panel and search for phpMyAdmin.

Make sure you have selected your WordPress database by clicking on the database name in your left hand column. After that you have to click on the SQL menu.

How to stop storing IP address in WordPress comments

This will bring you a text area where you should enter this query:

 ACTUALIZAR 'wp_comments' SET 'comment_author_IP' = "; 

Click the Go button below the text area to run your query. That's it, it will remove all IP addresses stored with comments in the WordPress database.

Note:If you have a custom WordPress database prefix, then set wp_comments to your custom table prefix.

We hope this article helped you learn how to stop storing IP addresses in WordPress comments. If you want, you can also see our guide on how to add. Ask me something anonymously in WordPress..

If you enjoyed this article, please subscribe to our WordPress YouTube Channel video tutorials. You can also find us on Twitter and Facebook.