The following code snippet will include all the form fields in the confirmation URL.
/**
* Include Form Fields on Confirmation URL
*
*/
function ea_wpforms_include_form_fields_on_confirmation( $url, $form_id, $fields ) {
$args = array();
foreach( $fields as $field ) {
if( !empty( $field['value'] ) )
$args['field_' . $field['id']] = $field['value'];
}
return esc_url_raw( add_query_arg( $args, $url ) );
}
add_filter( 'wpforms_process_redirect_url', 'ea_wpforms_include_form_fields_on_confirmation', 10, 3 );
If you want to only include a few fields, use the snippet below and update the $fields_to_include
array to be a list of the Field IDs you’d like to include.
/**
* Include Specific Form Fields on Confirmation URL
*
*/
function ea_wpforms_include_form_fields_on_confirmation( $url, $form_id, $fields ) {
$args = array();
$fields_to_include = array( 1, 4, 8 );
foreach( $fields as $field ) {
if( !empty( $field['value'] ) && in_array( $field['id'], $fields_to_include ) )
$args['field_' . $field['id']] = $field['value'];
}
return esc_url_raw( add_query_arg( $args, $url ) );
}
add_filter( 'wpforms_process_redirect_url', 'ea_wpforms_include_form_fields_on_confirmation', 10, 3 );