Gform_webhooks_request_data not running on a form submit [RESOLVED]

I have two forms, the first form on submit it redirects you to the second form. I am using gform_webhooks_request_data to run a function. When the first form submits, the function runs as expected, you’re redirected to the second form. When you submit the second form, this function does not run and I do not know why.

Here is the function that is in functions.php:

add_filter( 'gform_webhooks_request_data', 'hcii_modify_data', 10, 4 );
function hcii_modify_data( $request_data, $feed, $entry, $form ){

	// LOGGING
	GFCommon::log_debug( __METHOD__ . "(): This is the start of the function." );

	if (class_exists('GPDFAPI')) {
		$pdf_id = '64adccbdf3fc3';
		$entry_id = rgar( $entry, 'id' );
		$pdf_path = GPDFAPI::create_pdf( $entry_id, $pdf_id );

		if ( !is_wp_error( $pdf_path ) && is_file( $pdf_path ) ) {
			$pdfFileContents = file_get_contents( $pdf_path );
			$pdfEncoded = base64_encode( $pdfFileContents );

			// Delete PDF from temp path
			unlink( $pdf_path );

			// LOGGING
			GFCommon::log_debug( __METHOD__ . "(): This is the encoded PDF: {$pdfEncoded} event." );
		}
	}
  $request_data['Document'] = $pdfEncoded;
  return $request_data;

When the function runs on the first form, I get the logged messages. When the second form is submitted, none of the statements log which leads me to believe for some reason the function is not running when the second form is submitted.

Any thoughts?

Is there an active feed configured in the Form Settings > Webhooks area of the second form?

Hello Richard, yes, there is a webhook feed configured for both forms, all other aspects of the webhook feed for both forms is working. This one function is converts a PDF to be sent in the webhook feed. Function runs exactly as it should on form 1, it just won’t run for the second form. I even tried appending the second form’s ID to the gform_webhook_request_data_7 to target the form directly and that did not work either.

Turned out to be an error in the code inside the gform_webhook_request_data function that called the incorrect PDF ID to generate. This has been a fun journey into webhooks :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.