# Include Custom Profile Fields in Personal Data Exports

> Adds the custom user fields you list (such as phone or company) to the personal data export file WordPress creates under Tools > Export Personal Data.

- Type: PHP
- Runs: Run everywhere
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: gdpr, export, user-meta
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-export-user-meta/

## Code

```php
// User meta key => label shown in the export.
$wpide_export_user_meta = array(
    'phone'           => 'Phone number',
    'company'         => 'Company',
    'billing_country' => 'Country',
);

add_filter( 'wp_privacy_personal_data_exporters', function ( $exporters ) use ( $wpide_export_user_meta ) {
    $exporters['wpide-user-meta'] = array(
        'exporter_friendly_name' => 'Extra profile fields',
        'callback'               => function ( $email ) use ( $wpide_export_user_meta ) {
            $user = get_user_by( 'email', $email );
            $data = array();

            if ( $user ) {
                foreach ( $wpide_export_user_meta as $key => $label ) {
                    $value = get_user_meta( $user->ID, $key, true );
                    if ( '' !== $value && null !== $value ) {
                        $data[] = array( 'name' => $label, 'value' => is_scalar( $value ) ? (string) $value : wp_json_encode( $value ) );
                    }
                }
            }

            return array(
                'data' => $data ? array( array( 'group_id' => 'wpide-profile', 'group_label' => 'Extra profile fields', 'item_id' => 'user-' . ( $user ? $user->ID : 0 ), 'data' => $data ) ) : array(),
                'done' => true,
            );
        },
    );

    return $exporters;
} );
```

## Notes

List the meta keys your theme or plugins store for users, with the label you want in the export.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Include Custom Profile Fields in Personal Data Exports" 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/
