Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active January 31, 2019 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/7ebff6f2e44e27cd78de289e6535bd10 to your computer and use it in GitHub Desktop.
Save billerickson/7ebff6f2e44e27cd78de289e6535bd10 to your computer and use it in GitHub Desktop.
<?php
/**
* Include Form Fields on Confirmation URL
* @see https://www.billerickson.net/code/wpforms-pass-form-data-to-another-form/
*/
function be_wpforms_fields_on_confirmation( $url, $form_id, $fields, $form_data, $entry_id ) {
$classes = explode( ' ', $form_data['settings']['form_class'] );
if( ! in_array( 'fields-to-confirmation', $classes ) )
return $url;
$args = array();
foreach( $fields as $field ) {
if( !empty( $field['value'] ) )
$args['wpforms-' . $form_id . '-field_' . $field['id'] ] = $field['value'];
}
return esc_url_raw( add_query_arg( $args, $url ) );
}
add_filter( 'wpforms_process_redirect_url', 'be_wpforms_fields_on_confirmation', 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment