{"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":"2025-04-21T20:07:32","modified_gmt":"2025-04-21T19:07:32","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>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-&gt;get_form_settings( 'form_name' );   \/\/&lt;&lt;&lt;Set in form widget &gt; Content &gt; Form fields &gt; 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-&gt;get( 'fields' );\n    $FormFields = &#91;];\n    foreach ( $RawFields as $Id =&gt; $Field )\n        $FormFields&#91; $Id ] = $Field&#91;'value'];\n\n    $my_form_field_id = '';\n    if (isset($FormFields&#91;'my_form_field_id']))   \/\/&lt;&lt;&lt;Set in form widget &gt; Content &gt; Form fields &gt; Select the field &gt; Advanced &gt; ID\n      $my_form_field_id = $FormFields&#91;'my_form_field_id'];\n\n\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-&gt;replace_setting_shortcodes( $redirect_url );\n    $handler-&gt;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":7,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4637\/revisions"}],"predecessor-version":[{"id":4646,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4637\/revisions\/4646"}],"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}]}}