Route Fluent Forms Notifications by Department
Sends Fluent Forms email notifications to a different inbox depending on the department or topic chosen in the form.
Opens WPIDE on
Code
$wpide_ff_route_field = 'department';
$wpide_ff_routes = array(
// 'sales' => '[email protected]',
// 'support' => '[email protected]',
);
add_filter( 'fluentform/email_to', function ( $address, $notification, $data ) use ( $wpide_ff_route_field, $wpide_ff_routes ) {
$choice = isset( $data[ $wpide_ff_route_field ] ) && is_string( $data[ $wpide_ff_route_field ] ) ? $data[ $wpide_ff_route_field ] : '';
return isset( $wpide_ff_routes[ $choice ] ) && is_email( $wpide_ff_routes[ $choice ] ) ? $wpide_ff_routes[ $choice ] : $address;
}, 10, 3 );
Notes
Set the field name and add each option value with its address to the map at the top; Fluent Forms Pro also has conditional routing in the notification settings.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.