PDF output of 2 documents in Contact Form 7
-
Hello,
I successfull create an PDF of dates from Contact Form 7, but now I like to create another PDF (2 documents and one pdf of each document). The function I can’t use twice. I create this.
add_action('wpcf7_before_send_mail_2', 'wpcf7_update_email_body_2'); function wpcf7_update_email_body_2($contact_form) { if ( $contact_form->id == 1350 ) { $submission = WPCF7_Submission::get_instance(); if ( $submission ) { /* DEFINE CONSTANT AND GET FPDF CLASSES */ define ('FPDF_PATH',get_template_directory().'/fpdf/'); require(FPDF_PATH.'fpdf.php'); $posted_data = $submission->get_posted_data(); // SAVE FORM FIELD DATA AS VARIABLES $headline = utf8_decode('Test'); // Name und Anschrift $gender = $_POST['gender']; $firstname = utf8_decode($posted_data["first-name"]); $lastname = utf8_decode($posted_data["last-name"]); $firma = utf8_decode($posted_data["firma"]); $strasse = utf8_decode($posted_data["strasse"]); $hausnummer = utf8_decode($posted_data["hausnummer"]); $plz = utf8_decode($posted_data["plz"]); $ort = utf8_decode($posted_data["ort"]); $pdf = new FPDF(); $pdf->AddPage('P'); $pdf->SetDisplayMode(real,'default'); $pdf->SetFont('Arial','B',12); $pdf->SetLeftMargin(20); $pdf->SetRightMargin(20); $pdf->SetFont('Arial','',10); $pdf->SetFont('Arial','B',10); $pdf->SetXY(20, 100); $pdf->Write(5,$headline . "\n\n"); $pdf->SetXY(140, 45); $pdf->SetFont('Arial','',10); $pdf->Cell(7,5,"".date("d.m.Y")."", FALSE); $pdf->Write(4,"".$timestamp.""); $pdf->SetXY(20, 115); $pdf->Line(110, 260, 180, 260); $pdf->SetXY(110, 265); $pdf->Output(FPDF_PATH.'Test.pdf', 'F'); } } } add_filter( 'wpcf7_mail_components_2', 'mycustom_wpcf7_mail_components_2' ); function mycustom_wpcf7_mail_components_2($components){ if (empty($components['attachments'])) { $components['attachments'] = array(FPDF_PATH .'Test.pdf'); } return $components; }
The topic ‘PDF output of 2 documents in Contact Form 7’ is closed to new replies.