Reply Directly to People Who Fill In WPForms
Sets the Reply-To of WPForms notifications to the email address the visitor entered when no Reply-To is configured, so pressing Reply answers them.
Opens WPIDE on
Code
add_filter( 'wpforms_entry_email_atts', function ( $email, $fields ) {
if ( ! empty( $email['replyto'] ) ) {
return $email;
}
foreach ( (array) $fields as $field ) {
if ( isset( $field['type'] ) && 'email' === $field['type'] && is_email( $field['value'] ) ) {
$email['replyto'] = sanitize_email( $field['value'] );
break;
}
}
return $email;
}, 10, 2 );
Notes
Uses the first email field of the form; notifications with their own Reply-To setting are not changed.
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.