I am calling API to submit the data of my form.
To display the correct confirmation message if a call of API fail, I need to put my code into gform_pre_submission() hook, to be able to tell the user that the submition to my API fail or another message. (I do that in gform_confirmation() )
The issue I have is that into gform_pre_submission() I cant acces the file upload field. All other field work great with rgpost( “input_1” )
I tried :
rgpost( ‘input_1’ )
$entry[ ‘1’ ]
Nothing return me the actual file.
My code work in the gform_after_submission. But, If I do that in this hook, I cant display a custom message if a call fail…
I cant send here all my code cause its really large and contain personal data but you can just take this as example :
add_action( 'gform_pre_submission_2', 'after_submission_parrainage', 10, 2 );
function after_submission_parrainage($entry, $form)
GFCommon::log_error( (' $$$ '));
GFCommon::log_error( (rgpost( 'input_1' )));
GFCommon::log_error( (rgpost( 'input_27' )));
GFCommon::log_error( ($entry[ '28' ]));
GFCommon::log_error( (' $$$ '));
This return 0 data in the gform_pre_submission(), but return correct things in the gform_after_submission
PS : I already tried this : Read form data at gform_pre_submission
GFCommon::log_debug( __METHOD__ . '(): The POST => ' . print_r( $_POST, true ) );
It return me everything except the files.
Dont know if I can use that, can my API call is fired in gform_after_submission (cause pre_submission doesnt have the files).
I think gform_field_validation strike before gform_after_submission … So I cant know if my API call failed or not.
Will dig into it today If I found a solution I will post it here.
EDIT : In fact gform_field_validation is execute on every page of my form, this is not possible for me cause my API call need to be strike when the field is submited.
Just need to find the right hook to submit the form, call my API and display the good confirmation message right after
Also tryied to use this hook : gform_post_process - Gravity Forms Documentation
Same issue, I got all the field but not the 2 files.
Depending on how your API expects the file to be submitted (and response provided), the Gravity Flow outgoing webhook may be something you want to look at. It has hooked into filters that you could effectively think of it as running after gform_after_submission, with the ability to map response values into fields (without code) which display in confirmation or drive conditional logic.
For example, if your API needs the file mime-encoded, the example #7 from gravityflow_webhook_args shows how to mime encode the file.
If you’ve got more targeted questions related to the API formatting, please send us a support ticket and happy to help further.
Thanks for your answer, as a developper I was not really agree to use another API call, I allready use 3 different API, to put data into my CRM, upload file on office365 and auto complete the form.
What worked is to do all my API call in this hook :
after I use gform_confirmation()
With a global PHP variable, I pass if there is any error in my api call, and so, im able to display different message.
Idk why it took that much time to find out all the hook and stuff, but any it work now…