{"id":4637,"date":"2025-04-21T19:41:31","date_gmt":"2025-04-21T18:41:31","guid":{"rendered":"https:\/\/ibex.tech\/wordpress-sites\/?p=4637"},"modified":"2026-05-15T15:08:40","modified_gmt":"2026-05-15T14:08:40","slug":"form-submission-hooks","status":"publish","type":"post","link":"https:\/\/ibex.tech\/wordpress-sites\/page-builders\/elementor\/forms\/form-submission-hooks","title":{"rendered":"Form submission hooks"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Elementor submits its form via ajax, so you can&#8217;t just do a $_POST grab on a page submit. You need to use <a href=\"https:\/\/developers.elementor.com\/docs\/hooks\/forms\/#form-submission\" target=\"_blank\" rel=\"noreferrer noopener\">its hooks<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Form submit complete (with optional redirect)<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/**********************************************\n\/\/**********************************************\n\/\/********** ELEMENTOR FORM SUBMITTED **********\n\/\/**********************************************\n\/\/**********************************************\nadd_action( 'elementor_pro\/forms\/new_record', function( $record, $handler )\n{\n  $form_name = $record->get_form_settings( 'form_name' );   \/\/&lt;&lt;&lt;Set in form widget > Content > Form fields > Form name\n\n\n  if ($form_name == 'my_form_name')\n  {\n    \/\/----- HANDLE my_form_name FORM SUBMISSION -----\n\n    \/\/CREATE AN ARRAY OF ALL THE SUBMITED FORM FIELDS\n    $RawFields = $record->get( 'fields' );\n    $FormFields = &#91;];\n    foreach ( $RawFields as $Id => $Field )\n        $FormFields&#91; $Id ] = $Field&#91;'value'];\n\n    $Email = $FormFields&#91;'Email'] ?? '';   \/\/&lt;&lt;&lt;Set in form widget > Content > Form fields > Select the field > Advanced > ID\n\n    \/\/CHECK ENTERED VALUES\n    if (email_exists($Email))\n    {\n      $handler->add_error(\n        'Email',      \/\/&lt;&lt;&lt;The ID of the field to show the error message under\n        'An account with this email address already exists.'      \/\/&lt;&lt;&lt;The error message to show\n      );\n      $handler->is_success = false;\n      return;\n    }\n\n    \/\/FORM ACCEPTED\n    \/\/Cause a re-direct\n    \/\/(This will work on a form with nothing set in 'Actions after submit')\n    $redirect_url = '\/my_page2';\n    $redirect_to = $record->replace_setting_shortcodes( $redirect_url );\n    $handler->add_response_data( 'redirect_url', $redirect_to );        \/\/Set redirect action to handler\n\n  }\n\n}, 10, 2);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Elementor submits its form via ajax, so you can&#8217;t just do a $_POST grab on a page submit. You need to use its hooks. Form submit complete (with optional redirect)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[382],"tags":[],"class_list":["post-4637","post","type-post","status-publish","format-standard","hentry","category-forms"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/comments?post=4637"}],"version-history":[{"count":8,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4637\/revisions"}],"predecessor-version":[{"id":4807,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4637\/revisions\/4807"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/media?parent=4637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/categories?post=4637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/tags?post=4637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}