# 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.

- Type: PHP
- Runs: Admin only
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: comments, ip-address, roles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-hide-commenter-ips/

## Code

```php
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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide Commenter IP Addresses From Non-Administrators" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
