Tutorials

How to stop storing IP addresses in WordPress comments

I know that a lot of users respect their privacy in Internet. This is important to feel safe being online. If you are WordPress owner and you want to give to visitors some more privacy, think about 100% anonymous comments on website. I want to show you, how in a few fast steps, you can stop storing IP address in wordpress comments.

About wordpress comments

WordPress stores a lot of logs, like IP address of comment author. These are the default settings. As a privacy-protect WordPress creator, you can change this. How? I can show you right now!

Stop storing IP Address – plugin method

Install Remove IP plugin (you find this in WordPress repository). With this plugin every comment will have since now IP 127.0.0.1 – this is IP address used default by localhost (for example – for developers). IMPORTANT: With Remove IP plugin you can just change IP for new comments. If you have old comments, you can do this with another method (read below).

Stop storing IP Address – manual functions.php method

If you know, how to edit wordpress functions file, this method will be easy for you. This method is copy-paste. Just do this and that is all. Like a above plugin, php code does the same with IP addresses. Turns original IP address to localhost (127.0.0.1). Simple and smart.

1
2
3
4
5
6
add_filter('pre_comment_user_ip', 'skilledwp_anonymous_comment_ip');
function skilledwp_anonymous_comment_ip()
{    
	$localhost = "127.0.0.1";
	return $localhost;
}

Pro tip: If you don’t want to store any IP address, delete 127.0.0.1 from string. (change $localhost = “127.0.0.1”; to $localhost = “”;)

How to remove IP address from old comments?

A few steps to do:

  1. Log in to hosting panel and choose phpmyadmin
  2. Log in to phpmyadmin (use MySQL data from wp-config.php file)
  3. Select correct database (this from wp-config.php)
  4. Click SQL tab and run this SQL query:
1
UPDATE 'wp_comments' SET 'comment_author_IP' = '';

Pro Tip 2: remember to use correct prefix (default by installation is wp_) – if necessary, change it!

Click Send/Go and wait a few seconds. With this simple trick you changed every comment author IP to nothing! They disappeared.

I think now you know everything about wordpress comments and you learned how to stop storing ip addresses in wordpress comments. Feel free to share this page on your Facebook or Twitter.

Leave a Comment

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