1

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 );
Amr Ali
  • 29
  • 1
  • 10
  • This has already been answered: http://stackoverflow.com/a/29927336/4102617 – Pascale Apr 26 '17 at 13:29
  • 2
    Possible duplicate of [How to hook into Contact Form 7 Before Send](http://stackoverflow.com/questions/29926252/how-to-hook-into-contact-form-7-before-send) – Pascale Apr 26 '17 at 13:30
  • @Pascale i have tried all suggested solutions but yet with no luck. Before i submit any questions here i do my homework pretty well. But this time i failed to find any fix to get it work – Amr Ali Apr 26 '17 at 13:32
  • Are you sure your plugin is being run? If yes, are you sure that the hook isn't being called? What tests have you done to see where its failing? - I see that this question is a few weeks old now. I hope you figured it out! – Brian Jun 22 '17 at 15:26

0 Answers0