Is there any way to show the backend API response in our WordPress UI/contact form7 Page as a modal or toast?
I saw that u guys use “wpcf7_mail_sent” hook. is it possible to use “wpcf7_before_send_mail” hook and stop the form submitting if any errors occurred in backed. Because we’re using email validation part in backed because it’s lot affected to user experience.
open the plugin directory contact-form-to-any-api\includes\class-cf7-to-any-api.php Line number 169
instead of
$this->loader->add_action('wpcf7_mail_sent',$plugin_admin,'cf7_to_any_api_send_data_to_api');
Replace with
$this->loader->add_action('wpcf7_before_send_mail',$plugin_admin,'cf7_to_any_api_send_data_to_api');
@mayur8991 Thanks for the reply. I saw that we can change the plugin action.but my question is can we stop submitting the form and display the backend error message when backend/spring boot app throw an error?
class-cf7-to-any-api-admin.php > add this after line number 634
if($result) {
$api_response = json_decode( $result, true );
if(in_array("400", $api_response)){
add_filter('wpcf7_display_message', 'change_submission_msg',10,2);
function change_submission_msg($message, $status){
if('mail_sent_ok' == $status){
$message= 'We are unable to proceed with your request. Because the email address you entered is already on our server - so you probably have an account with us.';
}
return $message;
}
}
using that we can manage API side errors to display on cf7 forms like validation messages on fronted.