# Route WPForms Notifications by Department

> Sends WPForms email notifications to a different address depending on the department or topic the visitor picked, instead of one shared inbox.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: wpforms, notifications, routing
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wpforms-route-by-department/

## Code

```php
$wpide_wpf_route_field = 6; // Field ID of the drop-down or radio.
$wpide_wpf_routes      = array(
    // 'Sales'   => 'sales@yourdomain.com',
    // 'Support' => 'support@yourdomain.com',
);

add_filter( 'wpforms_entry_email_atts', function ( $email, $fields ) use ( $wpide_wpf_route_field, $wpide_wpf_routes ) {
    $choice = isset( $fields[ $wpide_wpf_route_field ]['value'] ) ? (string) $fields[ $wpide_wpf_route_field ]['value'] : '';

    if ( isset( $wpide_wpf_routes[ $choice ] ) && is_email( $wpide_wpf_routes[ $choice ] ) ) {
        $email['address'] = array( $wpide_wpf_routes[ $choice ] );
    }

    return $email;
}, 10, 2 );
```

## Notes

Set the field ID of the drop-down and add each choice label with its address to the map at the top; other choices keep the notification's own recipients.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Route WPForms Notifications by Department" 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/
