Exporting form results from Contact form 7 to PDF (fPDF)

后端 未结 5 1727
误落风尘
误落风尘 2021-01-07 05:23

I am trying to export the values that users input into Contact form 7 in WordPress, to PDF via fpdf. This is what I\'ve set up, I can generate a PDF but without the dynamica

5条回答
  •  醉酒成梦
    2021-01-07 06:06

    Since version 3.9 of Contact From 7, instead of using $cf7->posted_data, you can retrieve the posted data with:

    $submission = WPCF7_Submission::get_instance();
    
    if ( $submission ) {
        $posted_data = $submission->get_posted_data();
    }
    

    Now you have an array with the posted data which you can use to generate the PDF file:

    /* example code to generate the pdf */
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Times','B',16);
    $pdf->Write(5,  "My first name is: " . $posted_data['first-name'] );
    $pdf->SetFont('Arial','B',16);
    

提交回复
热议问题