Thread Starter
twig
(@stripytiger)
I have looked at the forminator_custom_form_submit_before_set_fields action, and if I could cancel the submit at this point if the membership number is invalid, that would be great. Thank you
Hi @stripytiger
I hope you are doing good today.
I pinged our Formiantor Team to review your query. We will post an update here as soon as more information is available.
Kind Regards,
Kris
Hello @stripytiger ,
I’m sorry for the delay on our end. Our developer suggested using forminator_custom_form_submit_errors. With it, you can check submitted fields there and return a custom error message if fields data are not valid.
Let us know if that helps.
kind regards,
Kasia
Thread Starter
twig
(@stripytiger)
Hi. Many thanks for this. I have tried it but it does not work as required – it may be me doing something wrong.
I have added an action in my plugin class like this
add_filter("forminator_custom_form_submit_errors", array($this,"ForminatorPreSubmit"),10,3);
Then I have this.
function ForminatorPreSubmit($submit_errors, $form_id, $field_data_array)
{
/** Do form_id check and any validation code here **/
$submit_errors[] = "Stripy Tiger has detected an error";
return $submit_errors;
}
This does stop the form submission, but the error displayed is
Error: Your form is not valid, please fix the errors!
And the form is then locked – so no changes can be made.
Many thanks for helping me.
Hi @stripytiger,
You can try something like this:
add_action( 'forminator_custom_form_submit_errors', function( $submit_errors, $form_id, $field_data_array ){
$submit_errors[]['custom_error'] = __('A new custom error.');
return $submit_errors;
}, 10, 3 );
You can also check the following snippet as an example too:
https://gist.github.com/patrickfreitasdev/12e75dd199799532875b319871904bf1
Kind Regards,
Nithin