Skip to content

Instantly share code, notes, and snippets.

@timersys
Last active July 9, 2018 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timersys/c1ed53aada37992d45069f0710e15e9e to your computer and use it in GitHub Desktop.
Save timersys/c1ed53aada37992d45069f0710e15e9e to your computer and use it in GitHub Desktop.
Open popup after ninja forms 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>
// Create a new object for custom validation of a custom field.
var myPopupsSubmitController = Marionette.Object.extend( {
initialize: function() {
this.listenTo( Backbone.Radio.channel( 'forms' ), 'submit:response', this.actionSubmit );
},
actionSubmit: function( response ) {
//insert popup ID here
SPU.show('529');
},
});
// On Document Ready...
jQuery( document ).ready( function( $ ) {
// Instantiate our custom field's controller, defined above.
new myPopupsSubmitController();
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment