# Send Wordfence Alerts to a Separate Address

> Redirects Wordfence's security alert emails to a dedicated address (such as your agency's monitoring inbox) and adds a site tag to the subject, without changing the site admin email.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: wordfence, security, email
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wordfence-route-alerts/

## Code

```php
$wpide_alerts_to = 'security@example.com'; // Recipient for Wordfence emails.
$wpide_tag       = '[' . wp_parse_url( home_url(), PHP_URL_HOST ) . ']'; // Added to the subject.

add_filter( 'wp_mail', function ( $args ) use ( $wpide_alerts_to, $wpide_tag ) {
    if ( ! defined( 'WORDFENCE_VERSION' ) || empty( $args['subject'] ) || false === stripos( $args['subject'], 'wordfence' ) ) {
        return $args;
    }

    $args['to'] = $wpide_alerts_to;

    if ( false === strpos( $args['subject'], $wpide_tag ) ) {
        $args['subject'] = $wpide_tag . ' ' . $args['subject'];
    }

    return $args;
} );
```

## Notes

Matches emails whose subject contains "Wordfence". Keep the address in Wordfence's own settings too if you want both to receive them.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Send Wordfence Alerts to a Separate Address" 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/
