Send PDF URL(s) to Zapier

If you’re using the official Gravity Forms Zapier add-on to funnel your entry data off to the endless multitudes of services Zapier allows you to integrate Gravity Forms with, you may want to also include your generated PDFs from Fillable PDFs along with that data.

Doing this isn’t possible out of the box, but through the addition of the following code utilizing the gfrom_zapier_request_body filter in your theme functions.php file or a custom functions plugin you can get that going and send off the URLs of any generated PDFs for the entry along with the rest of the payload being sent to Zapier.

Note: Be sure to change Fillable_PDF on line 33 to the name of the field on the Zapier end of things where you’d like the data to be transmitted to.

<?php
/**
* Add link to PDF generated by Fillable PDFs to Zapier request.
*
* @param array $body An associative array containing the request body that will be sent to Zapier.
* @param array $feed The feed object currently being processed.
* @param array $entry The entry object currently being processed.
* @param array $form The form object currently being processed.
*
* @return array
*/
add_filter( 'gform_zapier_request_body', function( $body, $feed, $entry, $form ) {
// If Fillable PDFs is not installed, exit.
if ( ! function_exists( 'fg_fillablepdfs' ) ) {
return $body;
}
// Get PDFs generated for entry.
$entry_pdfs = fg_fillablepdfs()->get_entry_pdfs( $entry );
// If no PDFs were found, exit.
if ( empty( $entry_pdfs ) ) {
return $body;
}
// Get URL for first PDF.
$pdf = array_shift( $entry_pdfs );
$pdf_url = fg_fillablepdfs()->build_pdf_url( $pdf, true );
// Add to Zapier request body.
$body['Fillable_PDF'] = $pdf_url;
return $body;
}, 10, 4 );