WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is already a related question at How do I turn off wordpress comments ability to capture a users ip address?

But is there a solution to do it for users/mods/admins only?

So that normal anonymous visitors will have their IPs stored but registered users not.

share|improve this question

Just add a check for the log in status:

add_filter( 'pre_comment_user_ip', 'wpse_53935_no_ip_for_logged_users');

function wpse_53935_no_ip_for_logged_users( $ip )
    return is_user_logged_in() ? 0 : $ip;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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