Title: wp_privacy_anonymize_data
Published: October 5, 2018
Last modified: February 24, 2026

---

# wp_privacy_anonymize_data( string $type, string $data ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#wp--skip-link--target)

Returns uniform “anonymous” data by type.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#parameters)󠁿

 `$type`stringrequired

The type of data to be anonymized.

`$data`stringoptional

The data to be anonymized. Default empty string.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#return)󠁿

 string The anonymous data for the requested type.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#source)󠁿

    ```php
    function wp_privacy_anonymize_data( $type, $data = '' ) {

    	switch ( $type ) {
    		case 'email':
    			$anonymous = 'deleted@site.invalid';
    			break;
    		case 'url':
    			$anonymous = 'https://site.invalid';
    			break;
    		case 'ip':
    			$anonymous = wp_privacy_anonymize_ip( $data );
    			break;
    		case 'date':
    			$anonymous = '0000-00-00 00:00:00';
    			break;
    		case 'text':
    			/* translators: Deleted text. */
    			$anonymous = __( '[deleted]' );
    			break;
    		case 'longtext':
    			/* translators: Deleted long text. */
    			$anonymous = __( 'This content was deleted by the author.' );
    			break;
    		default:
    			$anonymous = '';
    			break;
    	}

    	/**
    	 * Filters the anonymous data for each type.
    	 *
    	 * @since 4.9.6
    	 *
    	 * @param string $anonymous Anonymized data.
    	 * @param string $type      Type of the data.
    	 * @param string $data      Original data.
    	 */
    	return apply_filters( 'wp_privacy_anonymize_data', $anonymous, $type, $data );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L8314)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L8314-L8352)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_privacy_anonymize_data’, string $anonymous, string $type, string $data )](https://developer.wordpress.org/reference/hooks/wp_privacy_anonymize_data/)

Filters the anonymous data for each type.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_privacy_anonymize_ip()](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_ip/)`wp-includes/functions.php` |

Returns an anonymized IPv4 or IPv6 address.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#)

| Used by | Description | 
| [wp_comments_personal_data_eraser()](https://developer.wordpress.org/reference/functions/wp_comments_personal_data_eraser/)`wp-includes/comment.php` |

Erases personal data associated with an email address from the comments table.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_privacy_anonymize_data/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.6](https://developer.wordpress.org/reference/since/4.9.6/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_privacy_anonymize_data%2F)
before being able to contribute a note or feedback.