Hey team,
I have a form that redirects a user from the form to a pdf, the issue I’m having is both methods I’ve tried is causing the redirect to happen twice because of the iframe that’s embedded under the form, in turn running the script twice:
This happens when I do it this way:
add_filter( 'gform_confirmation', function ( $confirmation, $form, $entry, $ajax ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
$forms = array( 2 );
if ( ! in_array( $form['id'], $forms ) ) {
return $confirmation;
}
if ( isset( $confirmation['redirect'] ) ) {
$url = esc_url_raw( $confirmation['redirect'] );
GFCommon::log_debug( __METHOD__ . '(): Redirect to URL: ' . $url );
$confirmation = 'Thanks for downloading! A new tab should have opened with the brochure in it. If you have a popup blocker enabled you may need to <a href="https://www.towandcollect.com/us/wp-content/uploads/sites/2/2021/08/Tow-and-Collect-Catalouge-2021_WEB_compressed-1-1.pdf">click here to see the brochure.</a>';
$confirmation .= "<script type=\"text/javascript\">window.open('$url', '_blank');</script>";
}
return $confirmation;
}, 10, 4 );
And also when I do it in the confirmation it’s self:
I need to keep AJAX enabled for other functionality. Has anyone found a way around this?

