How to Stop Storing IP Address in WordPress Comments485

Author: InfoBeep - September 17, 2017 | subject to copyright

In order to protect privacy of your WordPress site post commenters, you may like to stop storing IP address in WordPress. Here, it is how you can do it.

Pros and Cons of not storing IP address in WordPress comments

Storing IP address in WordPress comments help you know about the details of your viewers.

Here, Pros of not storing IP address could be you are keeping the privacy of you site commenters. But on the other hand, you would have no idea about the commenters if you are not storing IP address.

Method 1: Stop storing IP address in comments plugin

This is the simplest method to stop storing IP address. You just need to install and activate ‘Remove IP’ plugin. This plugin will automatically replace your user IP with which is the same IP address used by localhost.

Method 2: Manually stop storing IP addresses with WordPress comments

In this method, you just need to copy the code given below and paste it to your theme’s functions.php file or a site-specific plugin.

function wpb_remove_commentsip( $comment_author_ip ) {

return '';


add_filter( 'pre_comment_user_ip', 'wpb_remove_commentsip' );

(note: this method leaves the IP field blank)

Remove IP address from old comments

The above two methods we use, stops storing IP address in WordPress. Now here, we will guide you to remove IP address from old comments. You may follow the steps below:

  • Login to WordPress and look for phpMyAdmin.
  • Now click on SQL menu as shown in the figure below:


  • Now enter the code below:
UPDATE 'wp_comments' SET 'comment_author_IP' = '';
  • Click on Go button after you are done.