Hi @jawadakr
I hope you’re well today and thank you for your question!
I think that should be doable as it would be similar to the way built-in integrations are created but I admit I’m not sure about details. I’ve passed it on to our developers and I’m waiting for their feedback on this.
Please stay tuned. We’ll update you here as soon as we get to know more about possible solutions.
Best regards,
Adam
Hi @jawadakr
I just got response from our developers and the good news is you just need a small piece of code. I have tested it on my own setup and it intercepts the form data nicely:
add_action( 'hustle_form_after_handle_submit', function( $module_id, $response ){
if ( ! isset( $response[ 'success' ] ) || empty( $response[ 'success' ] ) ) {
return;
}
$data = filter_input( INPUT_POST, 'data', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
parse_str( $data['form'], $form_data );
error_log( print_r( $form_data, true ) );
}, 20, 2 );
This snippet would print out all the form data to the debug.log file if debugging (with DEBUG_LOG) is enabled but to use it for other purposes you’d just want to replace this line
error_log( print_r( $form_data, true ) );
with a call to your own function that would do whatever you need to be done with form data. The $form_data variable is an array that stores all the fields values of the submitted form.
I hope that helps 🙂
Best regards,
Adam
Hi Adam
Thanks. That worked very well for me.
Hi Adam,
Good answer, I was looking for the same hook.
Worked perfectly.
Thank you!
There is a redundant condition here, in PHP a variable is considered empty if it does not exist:
if ( ! isset( $response[ 'success' ] ) || empty( $response[ 'success' ] ) ) {
This would be the same but slightly faster:
if ( empty( $response[ 'success' ] ) ) {
Hi @baras
I’m glad it helped you too!
As for “There is a redundant condition here, in PHP a variable is considered empty if it does not exist:” – yes, that’s “functionally” true but there’s a small “catch”. This “redundancy” here is pretty much only to make sure that no warnings will be triggered in case of unexpected issues which might cause the variable to actually exist but be empty. That’d be rare case and “functionally” would indeed be the same but on some setups (I’m not that good, I’m not sure why but I believe it’s related to PHP version/errror reporting settings) it would log a warning. I’ve seen that myself actually 🙂
Still though – your version would work exactly the same way and yes, it would be slightly faster (probably not “measurably” faster but faster) so it’s perfectly fine 🙂
Best regards,
Adam