Hello @dinesh2018wp ,
Can you share your full code? It seems that it is missing one argument: $form_id or $response, hence the Too few arguments to function function_Name() error.
kind regards,
Kasia
@wpmudev-support2
I am missing argument in add action, it shoud be like this
add_action( 'forminator_form_after_save_entry', 'function_Name', 10, 2 );
function function_Name($form_id, $response) {
error_log(print_r($response['select_field'], true));
$entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $form_id );
error_log(print_r($entry, true));
}
$response doesn’t return the form fields
log of $response
Array
(
[message] => Thank you for contacting us, we will be in touch shortly.
[success] => 1
[form_id] => 19
[behav] => behaviour-thankyou
[fadeout] => true
[fadeout_time] => 5000
[select_field] => Array
(
)
)
to get form fields using this
$entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $form_id );
this return the fields of last submitted form but this may cause issue when 2 more form summitted at same time , will you please help with correct way to get summited form fields
I can get form feilds with $_POST
is this correct way ?
Hello @dinesh2018wp,
I hope you’re doing well today!
Yes, you can find the field data in $_POST, and additional info (e.g. default options) by using get_post_meta().
You can also use $form_id to apply your code to a particular form. Please test the following example (replace 111 with your form ID):
add_action( 'forminator_form_after_save_entry', 'function_Name', 10, 2 );
function function_Name( $form_id, $response ){
if( $form_id != 111 ){ // change this number to your form ID
return;
}
$form_meta = get_post_meta($form_id, 'forminator_form_meta', true);
if( $form_meta ){
if( isset( $form_meta['fields'] ) ){
error_log(print_r($form_meta['fields'], true));
}
if( isset( $_POST ) ){
error_log(print_r($_POST, true));
}
}
}
Let us know if you have any questions.
Best Regards,
Dmytro
Hello @dinesh2018wp ,
We haven’t heard from you for over 2 weeks now, so it looks problem was solved with the above code.
Feel free to re-open this topic if needed.
Kind regards
Kasia