Frage

I have got a wordpress instance with the plugin contact-form-7. In some tutorials, I saw that I can do something before sending the mail with this code:

add_action("wpcf7_before_send_mail", "wpcf7_do_something_else");

function wpcf7_do_something_else(&$wpcf7_data) {

    // Here is the variable where the data are stored!
    var_dump($wpcf7_data);

    // If you want to skip mailing the data, you can do it...
    $wpcf7_data->skip_mail = true;

}

I got the code from here http://code.tutsplus.com/tutorials/mini-guide-to-contact-form-7--wp-25086

But somehow, it is not working. I don't receive any error - the contact form is not sending the mail anymore, even without the $wpcf7_data->skip_mail = true, and it doesn't print anything.

My questions:

Where do I have to write this code? Directly into the plugin? (At the moment, I wrote this code into a custom plugin, maybe wrong?) Is it even possible to print any data from the form in there? (Is the tutorial bad?)

Thanks!

War es hilfreich?

Lösung

Well, it is normal that the contact form does not send email anymore, as it is defined on this line $wpcf7_data->skip_mail = true;.

This code is used if you want something else than the default posting (sending in email), as described in the tutorial.

This code, however, should be placed in your theme's functions.php file (if file exists, create it). But still, the email will not be send.

If you want to skip emails and perform other action, then leave this piece of code

$wpcf7_data->skip_mail = true;

and add your logic after this line.

Describe more precisely what do you want to do (instead of sending email) in your question.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top