• Resolved Kevin Pirnie

    (@kevp75)


    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?

    • This topic was modified 1 year, 7 months ago by Kevin Pirnie.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Kevin Pirnie

    (@kevp75)

    I have tried it in template_redirect by catching the $_POST and ensuring one of the form fields is present and not empty, however, that is incredibly hacky and unreliable at best, as I am sure you know ??

    Same with init, and wpforms_frontend_output_success seems to do nothing

    Hey @kevp75 – I apologize as customizations like this are outside of our scope for support. In case you’d like to look into custom development options, we highly recommend using Codeable.

    Thanks!

    Thread Starter Kevin Pirnie

    (@kevp75)

    @prashantrai This is an issue with a method within WPForms, specifically: wpforms_process_complete

    Are you saying that you won’t support methodology your team developed?

    Thread Starter Kevin Pirnie

    (@kevp75)

    So be it.

    Hey @kevp75 – I sincerely apologize for the confusion. Generally providing support for custom code falls outside the scope of support we can offer on the www.ads-software.com support forum.

    Having said that, for your specific requirement, you can consider using wpforms_process_redirect_url or wpforms_process which should help you get started.

    Again, I sincerely apologize for the confusion, and if you have any questions, please feel free to reachout.

    Kindly,

    Thread Starter Kevin Pirnie

    (@kevp75)

    We are going to use a different form plugin. This can be closed

    Hey @kevp75 – I apologize for the initial confusion, and I respect your decision to go with a different plugin. That said, please know if you ever decide to give WPForms a try in the future, and have any questions, please feel free to reachout.

    Kindly,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘wpforms_process_complete Redirect Not Working’ is closed to new replies.