PHPackages                             arraypress/wp-anonymize-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/wp-anonymize-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/wp-anonymize-utils
=============================

A simple WordPress utility for anonymizing personal data (names, phones, addresses)

016PHP

Since Nov 16Pushed 6mo agoCompare

[ Source](https://github.com/arraypress/wp-anonymize-utils)[ Packagist](https://packagist.org/packages/arraypress/wp-anonymize-utils)[ RSS](/packages/arraypress-wp-anonymize-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WordPress Anonymize Utilities
=============================

[](#wordpress-anonymize-utilities)

A simple WordPress utility for anonymizing personal data including names, phone numbers, addresses, and generic text masking. Perfect for GDPR compliance and e-commerce privacy requirements.

Features
--------

[](#features)

- 🎯 **Focused API** - Just 6 essential methods for personal data anonymization
- 🔒 **Privacy Compliance** - Built for GDPR and privacy regulations
- 📦 **E-commerce Ready** - Perfect for WooCommerce and custom shop plugins
- 🪶 **Lightweight** - Single class, ~150 lines of code
- 🔧 **Global Functions** - Optional helper functions for convenience

Requirements
------------

[](#requirements)

- PHP 7.4 or later
- WordPress 5.0 or later

Installation
------------

[](#installation)

```
composer require arraypress/wp-utils-anonymize
```

Usage
-----

[](#usage)

### Using the Class

[](#using-the-class)

```
use ArrayPress\AnonymizeUtils\Anonymize;

// Anonymize names - preserves first and last letter
$name = Anonymize::name( 'John Smith' );
// Returns: "J**n S***h"

// Anonymize phone numbers - keeps last 4 digits
$phone = Anonymize::phone( '555-123-4567' );
// Returns: "*******4567"

// Anonymize addresses - preserves structure
$address = Anonymize::address( '123 Main Street' );
// Returns: "*** **** ******"

// Anonymize zip codes - keeps last 2 characters
$zip = Anonymize::zipcode( '90210' );
// Returns: "***10"

// Generic text masking
$text = Anonymize::text( 'sensitive', 2, 1 );
// Returns: "se******e"

// Bulk anonymize fields
$data = Anonymize::fields( [
    'billing_name' => 'John Doe',
    'billing_phone' => '555-1234',
    'billing_address' => '123 Main St'
] );
// Returns anonymized array with auto-detection
```

### Using Global Functions

[](#using-global-functions)

```
// Simple global functions for common operations
echo anonymize_name( 'Jane Doe' );        // "J**e D*e"
echo anonymize_phone( '555-1234' );       // "****1234"
echo anonymize_address( '456 Oak Ave' );  // "*** *** ***"
```

### E-commerce Example

[](#e-commerce-example)

```
use ArrayPress\Utils\Anonymize;

// GDPR compliance - anonymize customer data
class Order_Privacy {

    public function anonymize_order( $order_id ) {
        $order = wc_get_order( $order_id );

        // Anonymize billing information
        $order->set_billing_first_name( Anonymize::name( $order->get_billing_first_name() ) );
        $order->set_billing_last_name( Anonymize::name( $order->get_billing_last_name() ) );
        $order->set_billing_phone( Anonymize::phone( $order->get_billing_phone() ) );
        $order->set_billing_address_1( Anonymize::address( $order->get_billing_address_1() ) );
        $order->set_billing_postcode( Anonymize::zipcode( $order->get_billing_postcode() ) );

        $order->save();
    }
}
```

### Check if Data is Anonymized

[](#check-if-data-is-anonymized)

```
$name = 'J**n S***h';
if ( Anonymize::is_anonymized( $name ) ) {
    // Data has already been anonymized
}
```

Methods
-------

[](#methods)

### `name( string $name ): string`

[](#name-string-name--string)

Anonymizes names while preserving the first and last letter of each word.

### `phone( string $phone, int $keep_last = 4 ): string`

[](#phone-string-phone-int-keep_last--4--string)

Anonymizes phone numbers, keeping only the specified number of last digits.

### `address( string $address ): string`

[](#address-string-address--string)

Anonymizes addresses while preserving structure (spaces, punctuation, line breaks).

### `zipcode( string $zip, int $keep_last = 2 ): string`

[](#zipcode-string-zip-int-keep_last--2--string)

Anonymizes postal codes, keeping only the specified number of last characters.

### `text( string $text, int $show_first = 1, int $show_last = 1 ): string`

[](#text-string-text-int-show_first--1-int-show_last--1--string)

Generic text masking that shows only specified characters at start and end.

### `fields( array $data ): array`

[](#fields-array-data--array)

Bulk anonymize multiple fields with automatic type detection based on field names.

### `is_anonymized( string $text ): bool`

[](#is_anonymized-string-text--bool)

Check if text appears to be already anonymized (contains 3+ asterisks).

Why This Library?
-----------------

[](#why-this-library)

- **Focused** - Just personal data anonymization, nothing else
- **E-commerce Ready** - Built with WooCommerce/SugarCart needs in mind
- **GDPR Compliant** - Helps meet "right to be forgotten" requirements
- **Simple API** - Easy to remember methods that do one thing well
- **No Dependencies** - Just PHP and WordPress

Note on Email and IP Anonymization
----------------------------------

[](#note-on-email-and-ip-anonymization)

This library focuses on personal data (names, phones, addresses). For email and IP anonymization, use the dedicated utilities:

- [ArrayPress Email Utils](https://github.com/arraypress/wp-email-utils) for email anonymization
- [ArrayPress IP Utils](https://github.com/arraypress/wp-ip-utils) for IP anonymization

License
-------

[](#license)

GPL-2.0-or-later

Support
-------

[](#support)

- [Documentation](https://github.com/arraypress/wp-utils-anonymize)
- [Issue Tracker](https://github.com/arraypress/wp-utils-anonymize/issues)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance47

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (4 commits)")

### Embed Badge

![Health badge](/badges/arraypress-wp-anonymize-utils/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-wp-anonymize-utils/health.svg)](https://phpackages.com/packages/arraypress-wp-anonymize-utils)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
