5

I want to use a form from the Contact Form 7 plugin to allow the users to upload a document to my website. The problem is that I'd like to manage those uploads from WordPress instead of receiving them in my E-Mail.

Is there a way of redirecting the output of those forms to a PHP script, or something similar?

2 Answers 2

7

Take a look at the wpcf7_before_send_mail hook CF7 provides.

add_action("wpcf7_before_send_mail", "wpcf7_do_something_else_with_the_data");
function wpcf7_do_something_else_with_the_data(&$wpcf7_data)
{

    // Everything you should need is in this variable
    var_dump($wpcf7_data);

    // I can skip sending the mail if I want to...
    $wpcf7_data->skip_mail = true;

}
1
  • Wow, this is brilliant, exactly what I was looking for. Thank you! Mar 6, 2012 at 19:02
3

Using var_dump here is not a good idea because you will write the output to the buffer and break the form submission. Use error_log wordpress functions with print_r or var_dump with the following code instead :

ob_start();                      // start buffer capture
var_dump($wpcf7_data);           // dump the values
$contents = ob_get_contents();   // put the buffer into a variable
ob_end_clean();                  // end capture
error_log($contents);            // Write to wp-content/debug.log (enable debug mode to see it).

Not the answer you're looking for? Browse other questions tagged or ask your own question.