Skip to content

Instantly share code, notes, and snippets.

@timersys
Last active July 9, 2018 21:23
Show Gist options
  • Save timersys/3316397ada0c43d1ec5623b5f09c17a6 to your computer and use it in GitHub Desktop.
Save timersys/3316397ada0c43d1ec5623b5f09c17a6 to your computer and use it in GitHub Desktop.
Open popup after Gravity form submission - More on https://timersys.com/how-to-display-a-popup-after-user-submits-form/
<?php // don't add this tag
// Print javascript code in the footer of the site to trigger the popup upon form submission
add_action('wp_footer', 'add_popups_trigger_code',150 );
function add_popups_trigger_code(){
// show code on certain page, comment out to print code on every page
if( ! is_page(520) )
return;
?>
<script>
jQuery(document).ready(function(){
jQuery(document).bind('gform_confirmation_loaded', function(event, formId){
if(formId == 1) {
// run code specific to form ID 1 and popup 123
SPU.show('529');
} else if(formId == 2) {
// run code specific to form ID 2
SPU.show('529');
}
});
})
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment