playing around i finally figured it out… obviously thanks to @vard.
the following code send the file to the required FTP. Gonna run afew more tests and just make sure there are no more errors,
minor issue,. the Sumbit circle keeps turning even though request went through. should be easy to sort out though. Hope this helps someone out there.
add_action('wpcf7_before_send_mail', 'log_cf7');
function log_cf7($WPCF7_ContactForm) {
$submission = WPCF7_Submission::get_instance();
$data = $submission->get_posted_data();
$data2 = print_r($data, true);
$myfile = fopen($_SERVER['DOCUMENT_ROOT'] . "/tempFile.txt","wb");
fwrite($myfile, $data2);
$ftp_server="-";
$ftp_username="-";
$ftp_userpass="-";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
if(ftp_put($ftp_conn,"newdata.txt",$_SERVER['DOCUMENT_ROOT'] . "/tempFile.txt",FTP_ASCII))
{
print("yay");
}
else
{
print("f...");
}
fclose($myfile);
}
You can use the
wpcf7_before_send_mail
action in order to process your function before the mail is sent. Add the following to your functions.php file:$data
is an array containing your form content (key = input name, value = input value).To write to another server you can make use of PHP FTP.