This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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