How do I turn off wordpress comments ability to capture a users ip address?

The question:

Going through the comments table on my wordpress site, I noticed that wordpress is storing the ip address of everyone who makes a comment on my site. How do I remove this functionality?

I’m not just talking about the display of the ip in the template, I mean I don’t want wordpress to capture it in the first place.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Add this to your functions.php:

add_filter('pre_comment_user_ip', 'no_ips');
function no_ips($comment_author_ip){
  return '';

You’ll still have the comment_author_IP field in the db, but it will be empty…

And to remove existing IP records from the db run this query:

UPDATE `wp_comments` SET `comment_author_IP` = ''

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment