Skip to content

Instantly share code, notes, and snippets.

@karlpotter
Last active June 11, 2022 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlpotter/4172871b9ae8d507470676790efb7df2 to your computer and use it in GitHub Desktop.
Save karlpotter/4172871b9ae8d507470676790efb7df2 to your computer and use it in GitHub Desktop.
<?php
/**
* Add link to document generated by by Legal Signing 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 Legal Signing is not installed, exit.
if ( ! function_exists( 'fg_legalsigning' ) ) {
return $body;
}
// Get PDFs generated for entry.
$entry_pdfs = fg_legalsigning()->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_legalsigning()->build_pdf_url( $pdf, true );
// Add to Zapier request body.
$body['Legal_Signing'] = $pdf_url;
return $body;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment