Personal WPForms Confirmation Message
Greets visitors by their first name in the WPForms confirmation message after submitting, which feels friendlier than a generic thank-you.
Opens WPIDE on
Code
$wpide_wpf_greeting = 'Thanks, %s!'; // %s is the first name.
add_filter( 'wpforms_frontend_confirmation_message', function ( $message, $form_data, $fields ) use ( $wpide_wpf_greeting ) {
foreach ( (array) $fields as $field ) {
if ( isset( $field['type'] ) && 'name' === $field['type'] && ! empty( $field['value'] ) ) {
$first = ! empty( $field['first'] ) ? $field['first'] : strtok( (string) $field['value'], ' ' );
return '<p class="wpide-greeting"><strong>' . esc_html( sprintf( $wpide_wpf_greeting, $first ) ) . '</strong></p>' . $message;
}
}
return $message;
}, 10, 3 );
Notes
Uses the first Name field; the greeting is added before your existing confirmation text.
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.