Last active
December 10, 2021 08:31
-
-
Save marklchaves/50d011593cbe93e859a25abba1527a6d to your computer and use it in GitHub Desktop.
Try overriding the Gravity Forms default confirmation with a Popup Maker popup using either a GF hook or with jQuery.
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
/* Try this code in the footer area of your page if the PHP hook below doesn't work. */ | |
jQuery(document).ready(function ($) { | |
// Replace 123 and 456 with your respective popup IDs throughout. | |
$("#pum-123").on("pumBeforeOpen", function () { | |
const $gfConfirmation = $("#gform_confirmation_message_2"); // Replace 2 with your form's ID. | |
if ($gfConfirmation.length) { | |
console.log(`%c[PUM] Confirmation loaded for Gravity Forms form #2.`, 'color:orangered;font-size:16px'); | |
PUM.preventOpen(123); // First popup with the GF form. | |
PUM.open(456); // Thank you popup. | |
} | |
}); // Listener | |
}); // jQuery |
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 // Ignore this first line when copying to your child theme's functions.php file. | |
/** | |
* || Gravity Forms Confirmation Override | |
* | |
* Reference https://docs.gravityforms.com/gform_confirmation/ | |
*/ | |
function custom_confirmation_message( $confirmation, $form, $entry, $ajax ) { | |
$confirmation = "<script>window.top.jQuery( document ).on( 'gform_confirmation_loaded', function () { PUM.close( 123 ); PUM.open( 456 ); } );</script>"; | |
return $confirmation; | |
} | |
add_filter( 'gform_confirmation_2', 'custom_confirmation_message', 10, 4 ); | |
// Replace 123 and 456 with your popup IDs and add the updated snippet to your child theme's functions.php file. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment