4

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.

5

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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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