I've created the a custom gform_pre_submission_filter to run upon form submission.
It calls a function to generate a PDF and should display a custom confirmation message upon success. The generate PDF call works, but the custom confirmation message is not displayed on the results page (it displays the default conformation instead).
The filter code is as shown:
add_action("gform_pre_submission_filter_1", "get_ceu_pdf", 10, 2);
function get_ceu_pdf($form) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if (is_plugin_active('ce-certificates/ce-certificates.php')) {
// Set form values
$course_id = $_POST['input_5'];
$user_id = $_POST['input_4'];
$certificate_date = $_POST['input_6'];
$license_number = $_POST['input_2'];
$send_email = $_POST['input_7'];
// Plugin is activated, generate and email certificate
$cert_name = ce_generate_certificate($course_id, $user_id, $certificate_date, $send_email);
// Output confirmation message
$form["confirmation"]["type"] = "message";
$html_message = '<div class="ce-message">';
$html_message .= '<h3>Certificate Issued</h3>';
if ($cert_name) {
$html_message .= '<p>You may download the course certificate <a href="'.CE_CERTIFICATES_UPLOAD_URL.$cert_name.'" target="_blank">here</a></p>.<p>Your certificate has also been emailed to chosen user at the provided email.</p>';
} else {
// Cert generation failed
$html_message .= '<strong>Sorry, an error has occurred generating your certificate.</strong>';
}
$html_message.= '</div>';
$form["confirmation"]["message"] = $html_message;
}
return $form;
}
Should this filter work as coded?
Thanks,
John