Steve40 Posted August 22, 2021 Share Posted August 22, 2021 Greetings! I'm kinda learning php as I go along here (though I do have some experience in other languages), so I'm hoping someone can point me in the right direction. I'm using an add_action() function in functions.php to access the form data from an Elementor form. Works fine from within add_action(), however I cannot access any of the variables created from elsewhere within functions.php (tried adding a return). There's probably an easy solution, but I've been wracking my brains all weekend, and haven't gotten anywhere. Any thoughts? Side Thought: I've also tried do_shortcode(), which does retrieve the information I need, but it seems to modify it somehow, so comparison opperators return as false, even though they are visually equal. add_action( 'elementor_pro/forms/new_record', function( $record ) { $form_name = $record->get_form_settings( 'form_name' ); if ( 'MyElementorForm' !== $form_name ) { return; } $raw_fields = $record->get( 'fields' ); $fields = []; foreach ( $raw_fields as $id => $field ) { $fields[ $id ] = $field['value']; } $letter_type = $fields['LetterType']; // Send Test Email // if($letter_type === "1"){ $message = "Upload"; } elseif($letter_type === "0"){ $message = "PDF"; } else { $message = "Fail " . gettype($letter_type) . " " . $letter_type; } mail( "my@email_address.com", "Test", "Test Message " . $message ); }, 10, 2); Quote Link to comment https://forums.phpfreaks.com/topic/313588-accessing-elementor-form-fields/ Share on other sites More sharing options...
requinix Posted August 23, 2021 Share Posted August 23, 2021 What kind of variables do you want? Where did they get their values? Quote Link to comment https://forums.phpfreaks.com/topic/313588-accessing-elementor-form-fields/#findComment-1589299 Share on other sites More sharing options...
Strider64 Posted August 23, 2021 Share Posted August 23, 2021 I would suggest to find a recent good online PHP tutorial or a recent PHP How-to-code book to get familiar with programming in that language. Quote Link to comment https://forums.phpfreaks.com/topic/313588-accessing-elementor-form-fields/#findComment-1589306 Share on other sites More sharing options...
maxxd Posted August 23, 2021 Share Posted August 23, 2021 Sounds like you want a custom form action: https://developers.elementor.com/forms-api/custom-form-action/ I've only played with Elementor so I could be wrong, but it sounds right. Quote Link to comment https://forums.phpfreaks.com/topic/313588-accessing-elementor-form-fields/#findComment-1589307 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.