Elementor submits its form via ajax, so you can’t just do a $_POST grab on a page submit. You need to use its hooks.
Form submit complete (with optional redirect)
//**********************************************
//**********************************************
//********** ELEMENTOR FORM SUBMITTED **********
//**********************************************
//**********************************************
add_action( 'elementor_pro/forms/new_record', function( $record, $handler )
{
$form_name = $record->get_form_settings( 'form_name' ); //<<<Set in form widget > Content > Form fields > Form name
if ($form_name == 'my_form_name')
{
//----- HANDLE my_form_name FORM SUBMISSION -----
//CREATE AN ARRAY OF ALL THE SUBMITED FORM FIELDS
$RawFields = $record->get( 'fields' );
$FormFields = [];
foreach ( $RawFields as $Id => $Field )
$FormFields[ $Id ] = $Field['value'];
$my_form_field_id = '';
if (isset($FormFields['my_form_field_id'])) //<<<Set in form widget > Content > Form fields > Select the field > Advanced > ID
$my_form_field_id = $FormFields['my_form_field_id'];
//Cause a re-direct
//(This will work on a form with nothing set in 'Actions after submit')
$redirect_url = '/my_page2';
$redirect_to = $record->replace_setting_shortcodes( $redirect_url );
$handler->add_response_data( 'redirect_url', $redirect_to ); //Set redirect action to handler
}
}, 10, 2);
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.