# Add customer emails to order, customer and user replies

> Royal MCP leaves email addresses out of order, customer and user replies. Site owners can add them with three filters and a ready-made mu-plugin.

- Canonical: <https://royalplugins.com/support/royal-mcp/exposing-customer-email-via-filter/>
- HTML version: <https://royalplugins.com/support/royal-mcp/exposing-customer-email-via-filter/>

---

Royal MCP leaves email addresses out of the replies from its WooCommerce order and customer tools and its user tools. If you run the site and want your AI client to see them, for example to send follow-up material to everyone who bought a workshop, you can add them yourself with three filters. Requires Royal MCP 1.5.11 or later.

### Treat your connection like a password

Once you add these fields, every AI client connected to your site with an account that can use these tools can read your customers’ email addresses. Only do this on a site where you control every connection, and remove the file to switch it off.

## What the filters change

Nothing changes until you add a filter. Each filter receives the row a tool is about to return and can add fields to it:

| Filter | Tools | Arguments |
| --- | --- | --- |
| `royal_mcp_wc_order_fields` | `wc_get_orders`, `wc_get_order` | `$fields`, the `WC_Order`, and `'summary'` (order list) or `'detail'` (single order) |
| `royal_mcp_wc_customer_fields` | `wc_get_customers` | `$fields`, the `WP_User`, the `WC_Customer` |
| `royal_mcp_user_fields` | `wp_get_users`, `wp_get_user` | `$fields`, the `WP_User`, and `'list'` or `'single'` |

The filters run after each tool’s own permission check (`manage_woocommerce` for the WooCommerce tools, `list_users` for the user tools), so they only shape rows the connected account could already see. A filter that returns anything other than an array is ignored and the row is returned as built.

## Install the ready-made mu-plugin

#### Step 1 — Open your mu-plugins folder

Using your host’s file manager or SFTP, go to `wp-content/mu-plugins/`. Create the folder if it doesn’t exist. Files in this folder load automatically; they don’t appear in the normal Plugins list and can’t be switched off from WP Admin.

#### Step 2 — Save the file

Create `royal-mcp-customer-email.php` in that folder and paste in the code below.

#### Step 3 — Check it

Ask your AI client for a recent order. The reply now includes `billing_email`; customer and user replies include `email`.

```
<?php
/**
 * Plugin Name: Royal MCP — Expose Customer Email
 * Description: Adds billing_email to WooCommerce order and customer responses,
 *              and email to user responses. Site-owner opt-in: drop this file
 *              into wp-content/mu-plugins/ to enable, delete it to disable.
 * Requires Royal MCP 1.5.11 or later.
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

add_filter( 'royal_mcp_wc_order_fields', function ( $fields, $order, $context ) {
	$fields['billing_email'] = $order->get_billing_email();
	return $fields;
}, 10, 3 );

add_filter( 'royal_mcp_wc_customer_fields', function ( $fields, $user, $customer ) {
	$fields['email'] = $user->user_email;
	return $fields;
}, 10, 3 );

add_filter( 'royal_mcp_user_fields', function ( $fields, $user, $context ) {
	$fields['email'] = $user->user_email;
	return $fields;
}, 10, 3 );
```

## Only add what you need

The context argument lets you be narrower. This version adds the billing email to single-order lookups only, so long order lists stay short:

```
add_filter( 'royal_mcp_wc_order_fields', function ( $fields, $order, $context ) {
	if ( 'detail' === $context ) {
		$fields['billing_email'] = $order->get_billing_email();
	}
	return $fields;
}, 10, 3 );
```

The same pattern works for other order fields WooCommerce stores, such as `get_billing_phone()`. Add only what your workflow needs.

## Turn it off

Delete `royal-mcp-customer-email.php` from `wp-content/mu-plugins/`. Replies go back to leaving email addresses out straight away; there is no setting to reset.

## Still stuck?

### Community support (free)

Post a new thread at [wordpress.org/support/plugin/royal-mcp/](https://wordpress.org/support/plugin/royal-mcp/). The Royal Plugins team monitors the forum regularly.

### Premium support (paid)

For direct one-on-one help with a 24-hour SLA, see [Premium Support](https://royalplugins.com/premium-support/).

## Related

[WooCommerce tools

Every order, customer, product and coupon tool, with paging and date filters.](https://royalplugins.com/support/royal-mcp/woocommerce-tools/)
[API keys

How connections sign in, and how to rotate a key.](https://royalplugins.com/support/royal-mcp/api-keys/)
[Safety and recovery

Read-only mode, drafts-only mode and undo for AI changes.](https://royalplugins.com/support/royal-mcp/safety-and-recovery/)

[Back to WooCommerce tools](https://royalplugins.com/support/royal-mcp/woocommerce-tools/)
[Royal MCP Support Hub](https://royalplugins.com/support/royal-mcp/)
