Table of Contents
Can I Perform Extra Actions After a Form Submission? #
Yes, you can.
Even though 3rd-party form plugins have their own way of handling form submissions, Popup Maker v1.9+ provides a PHP hook you can use to run code after successful submissions.
What’s more, this single hook can reliably support AJAX & non-AJAX-based forms!
Add the following code to your site using the following options:
- Child theme: Add the snippet to your child theme’s
functions.php
file - Theme settings: Use your theme’s custom code settings or snippets area
- Code snippets plugin: Use a 3rd-party plugin that can add PHP code to your site
/** * This hook fires after any integrated form is submitted successfully. * * It does not matter if the form is in a popup or not. * * @since 1.9.0 * * @param {Object} form JavaScript DOM node or jQuery object for the form submitted * @param {Object} args { * @type {string} formProvider Such as `gravityforms` or `ninjaforms` * @type {string|int} formId Usually an integer ID number such as 1 * @type {int} formInstanceId Not all form plugins support this. * @type {string} formKey Concatenation of provider, ID & Instance ID. * @type {int} popupId The ID of the popup the form was in. * @type {Object} popup Usable jQuery object for the popup. * } */ PUM.hooks.addAction('pum.integration.form.success', function (form, args) { // Do something useful here. });
Do you need help with adding custom PHP to your site? Check out our Getting Started with Custom PHP guide.