I am trying to do some actions before submitting contact form 7 data. I am stuck at the point where i try to test the function prior to going live. I have tried all suggested solutions but unfortunately with no luck.
Here is the code i am currently using but with no luck given that i am placing the below code in a 3rd party plugin called My Custom Functions in Wordpress and i do not use any cache plugins. Any help
function action_wpcf7_before_send_mail( $contact_form ) {
$contact_form_name = 'Tour Booking Form';
if ($contact_form->name() == $contact_form_name) {
$message = "wrong answer";
echo "<script type='text/javascript'>alert('$message');</script>";
}
};
add_action( 'wpcf7_before_send_mail', 'action_wpcf7_before_send_mail', 10, 1 );