Site icon Thetechhacker

How to Remove and Stop Storing IP Address in WordPress Comments

The default WordPress comment system always stores IP addresses of the users when they leave a comment on one of your articles. This is a great favor in case you needed to block them if they are continuously trying to spam the comments. However, it is not likely to store the user information without their knowledge, especially if you have a Privacy Policy promising the user privacy.

Whatever the reason is, if you ever wanted remove and stop storing IP addresses of the users when they leave a comment on your articles, this guide is for you. Follow the steps given in this article to get rid of the IP address storing in WordPress comments.

Note: Before doing any changes mentioned in this article, we strongly recommend you to take a backup of your entire Database and files as we always recommend. A good backup is not only favorable for removing the IP address, but can always put you in a safe zone.

Also Read: How To Stop Unwanted Trackbacks and Pingbacks In WordPress

To do this, you just have to add some lines to the functions.php file of your current theme. We think, you are familiar with the basic steps to it. You can also use some plugins like code snippets to do the job. So, coming to the matter. Open your functions.php located in the current theme folder and add the following code to the end of the file.

//Stop recording IP address in comments
function mte_remove_commentsip( $comment_author_ip ) {
return ''; }
add_filter( 'pre_comment_user_ip', 'mte_remove_commentsip' );

This code simply removes the IP address before it’s being recorded to the database of your website. So, no more IP’s will be recorded.

If you don’t want to mess up of these things and need a safer way of stopping the IP recording in WordPress comments, there is a WordPress plugin called Remove IP which can simply do the job for you. You just have to install and activate it on your website and the plugin will automatically block IP recording. No configurations or setting tweaks and needed.

Now, you have successfully stopped recording IP addresses in your WordPress comment system. Now, what about the already recorded IPs? They are already there on the database of your website. If you don’t want to remove them, just leave it there. But, in case you want to get them removed, follow these steps.

  1. Login to your CPanel account.
  2. Search or find the phpMyAdmin.
  3. Open it and select your database from the left panel.
  4. Now, navigate to the SQL tab to run a custom SQL query for removing the stores IPs.
  5. In the text box, enter the following command and click on the Go button.
    UPDATE wp_comments SET comment_author_IP = '';
  6. After executing the command, you will receive a notification saying how much rows are affected.
  7. Now you’ve successfully removed the stored IP addresses from your database.

If you’ve faced any problems in the above step or needed any help, feel free to leave a comment. We will be happy to assist you.

Image Credit: NeilPatel

Exit mobile version