Skip to content

Instantly share code, notes, and snippets.

@travislopes
Last active July 2, 2020 16:37
Show Gist options
  • Save travislopes/2592133aa18e028d80549bdcfe547655 to your computer and use it in GitHub Desktop.
Save travislopes/2592133aa18e028d80549bdcfe547655 to your computer and use it in GitHub Desktop.
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment