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.

up vote 5 down vote accepted

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` = ''
  • thank you very much! That was a very nice little hidden gem of a function. – shawn Jun 22 '11 at 10:05
  • 4
    You could just set __return_zero() as filter function. No need to create a new one. :) – fuxia Jun 1 '12 at 9:34

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.