Skip to content

Instantly share code, notes, and snippets.

@andrewjmead
Last active March 22, 2025 20:31
Show Gist options
  • Save andrewjmead/a5ba8d613c90a800656ca74d015d5950 to your computer and use it in GitHub Desktop.
Save andrewjmead/a5ba8d613c90a800656ca74d015d5950 to your computer and use it in GitHub Desktop.
JetFormBuilder form submission hook for WordPress
<?php
/**
* JetFormBuilder has no documentation about what hooks they fire or when they fire them.
*
* I ended up digging into their source code to try and find an action that fires for all
* form submission, even if they don't have a custom "post submit action" set up.
*
* Using jet-form-builder/form-handler/after-send gets the job done.
*/
add_action('jet-form-builder/form-handler/after-send', function ($form) {
if (!$form->is_success) {
return;
}
$form_id = intval($form->form_id);
$post = get_post($form_id);
if (is_null($post)) {
return;
}
$form_title = $post->post_title
// Success!
// Do something with form_id and form_title and other data on form...
});
@devab7
Copy link

devab7 commented Jan 30, 2025

Hi, I am trying to block the IP after a form submission so that it cannot be submitted again for 5 minutes. The problem is that I can't find a way to stop the submission. Using the add_filter, I send a message below the form stating that the IP is blocked, but the form still gets submitted and registers a user. Could you help me or do you have any idea how to solve this, please?

@morosmo
Copy link

morosmo commented Mar 22, 2025

@devab7 Needed same kind of thing with my form too:

I have a custom hook called check_email in JetFormBuilder. This hook checks whether an email exists in the database.

Expected Behavior:
If the email exists, the hook should return true (or "approved"), allowing the form to proceed with the next action.

If the email does not exist, the hook should return false (or "rejected"), preventing further actions from executing.

Issue:
I am unsure how to make JetFormBuilder process actions conditionally based on my hook’s return value. How can I return "approve" or "reject" and use this result to control form execution?

Any guidance would be appreciated!

But not able to find how to stop excution of form or conditonaily run a specific action based on Custom hook results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment