How to Stop Storing IP Address of WordPress Commenters – 2 Easy Methods

After reading our entire article on how to create a custom Add to Cart URL in WooCommerce, one of my readers asked me how to stop storing the IP address of the people who write comments on my blog articles or who leave product reviews on my WooCommerce products.

Many bloggers or site owners want to do that in order to protect their audience privacy. In this article, I have explained to you how to stop storing the IP address of the user who leaves a comment on your WordPress blog or WooCommerce Products as product reviews.

stop storing IP address

Pros and Cons of not storing an IP address in WordPress comments

Natively, WordPress stores the IP addresses of people who leave comments on your website. These unique IP addresses are stored in your WordPress database until you manually delete them.

There is a reason for storing an IP address with each comment in WordPress. It helps the site owner to combat unwanted and spamming comments. The popular WordPress plugin Akismet block comments from those IP addresses which are exploited by spammers.

If your user is using a Virtual Private Network (VPN) then his/her IP address cannot be found in your site’s log otherwise you can have the real IP address in your site log.

There are many web hosting providers who have access log to all the visitors for a limited juncture of time like Cloudways, WP Engine, Kinsta, etc.

You can improve the privacy of your website commenter by not storing his IP address in your WordPress comments. This makes him more confident that you are not storing any of his IP address details to your website and will enhance him to write his comment without any worry.

Method 1: By using a WordPress plugin

Well, if you are a newbie and have a weak hand on the coding part then this method is recommended for you which is easier and quicker.

Step 1: You need to install the Remove IP(by guid0) plugin which is free to download from WordPress.org directory.

Step 2: Activate the plugin.

Now, once you activate this plugin, the original IP address of the user will be replaced by a default localhost IP address which is 127.0.0.1.

This plugin does not delete any of the existing IP address in your site’s older comments. If you have IP addresses in the older comments then those IP addresses need to be deleted too which I have explained at the end of this article.

Method 2: By adding a code snippet in functions.php file

If you are familiar with copying and pasting the code snippets in WordPress then this is the best method for you.

Just go to your theme’s functions.php file and paste this code at the very end.

function wsg_remove_commentsip( $comment_author_ip )

{
return ”;
}
add_filter( ‘pre_comment_user_ip’, ‘wsg_remove_commentsip’ );

This code working mechanism is same as of the plugin mentioned in method 1. I do not recommend to use a lot of plugins as they slow down your WordPress website. If you are also the one who is facing speed issues with WordPress website then switch your website to Cloudways for faster loading.

Method 3: Removing IP address from older comments

It’s total up to you of what method you choose to stop storing the IP addresses on WordPress comments but the older comments still have IP addresses stored with them.

And of course, as you are spending time to read this entire article, you may want to remove those IP address which is already stored with older comments.

I will show you by running one line of MySQL query on your WordPress database but make sure that you have downloaded the most recent WordPress database backup.

Now, follow these steps to run the MySQL query.

Step 1: Login into your web hosting cPanel.

Step 2: Search for phpMyAdmin option.

phpMyAdmin

Step 3: Now, click on your WordPress website database in the left column. (Don’t know what database it is? Go to your website’s wp-config.php file and check what database name is written over there).

Database name

Step 4: Click on the SQL menu.

Stop storing IP address WordPress

Paste the code given below in the white area under the SQL menu and hit the “Go” button to run this query.

UPDATE ‘wp_comments’ SET ‘comment_author_IP’ = ”;

Once you click on the “Go” button, this query executes and will remove all the existing IP addresses in your WordPress older comments.

I hope this article helped you to stop storing IP addresses with comments on the WordPress website.

Please subscribe to my Youtube channel for video tutorials and follow me on Twitter and Facebook for social media engagement.

This website contains affiliate links. If you click through and make a purchase, I may receive a commission at no additional cost to you. Thank you for supporting this site.

Was This Article Helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *