Hide Commenter IP Addresses From Non-Administrators
Hides commenters' IP addresses in the Comments screens for editors, moderators and authors, so only administrators can see this personal data.
Opens WPIDE on
Code
add_filter( 'get_comment_author_IP', function ( $ip ) {
return current_user_can( 'manage_options' ) ? $ip : '';
}, 20 );
Notes
Administrators (users who can manage options) still see the full IP address.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.