wpforms_process_complete Redirect Not Working
-
Hello,
I have a form that “must” be filled before it generates a PDF for the end user.
I am hooking into wpforms_process_complete to do this (for a specific form ID), and I have everything working fine include the PDF generation… but now I am attempting to redirect to another page after said PDF is presented, and nothing happens.
The basics are like this:
// hook into the forms processing completion add_action( 'wpforms_process_complete', function( $fields, $entry, $form_data, $entry_id ) { // make sure we're hooking the right form if ( absint( $form_data[ 'id' ] ) !== 387 ) { // whoops, not this one return; } // fire up the pdf generator $copay_pdf = new MYPDFGen( ); // build the PDF path $pdf_path = str_replace( '..', '', $copay_pdf -> output_dir . $copay_pdf -> pdf_output_file ); $pdf_path = wp_normalize_path( $pdf_path ); // present the PDF for download header( $_SERVER['SERVER_PROTOCOL'] . ' 200 OK' ); header( 'Content-Type: application/octet-stream' ); header( "Content-Disposition: attachment; filename=" . $copay_pdf -> pdf_output_file ); // read the file readfile( $pdf_path ); // delete it if( is_file( $pdf_path ) ) { unlink( $pdf_path ); } // redirect home wp_redirect( home_url( ) ); wp_die( ); }, 10, 4 );
Every bit of the above works properly minus the redirect.
One more note… I did turn off Ajax on the form.
Any ideas?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘wpforms_process_complete Redirect Not Working’ is closed to new replies.