title: Contact Form 7 and FPDF
body: <p>I have been following several topics on wordpress.org about saving the data submitted in Contact Form 7 and sending it to the the submitter as a PDF attachment.</p>
  
  <p><a href="https://wordpress.org/support/topic/convert-pdf-file" rel="nofollow noreferrer">https://wordpress.org/support/topic/convert-pdf-file</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27094291/exporting-form-results-from-contact-form-7-to-pdf-fpdf">Exporting form results from Contact form 7 to PDF (fPDF)</a></p>
  
  <p>Im using Kory's php in my functions and have uploaded fpdf to me theme file in a folder called fpdf plus added in [attachments] to my contact form in wordpress admin.</p>
  
  <p>My error is that the contact form doesn't submit. Just loads. Any ideas? </p>
  
  <p>My Form - <a href="http://www.mikeandtom.co.uk/ctest" rel="nofollow noreferrer">http://www.mikeandtom.co.uk/ctest</a></p>
  
  <pre><code>add_action('wpcf7_before_send_mail', 'wpcf7_update_email_body');
  function wpcf7_update_email_body($contact_form) {
  
  $submission = WPCF7_Submission::get_instance();
  if ( $submission ) {
  /* DEFINE CONSTANT AND GET FPDF CLASSES */
  define ('FPDF_PATH',get_template_directory().'/fpdf/'); // MAKE SURE THIS POINTS      TO THE DIRECTORY IN YOUR THEME FOLDER THAT HAS FPDF.PHP 
  require(FPDF_PATH.'fpdf.php');
  
  $posted_data = $submission-&gt;get_posted_data();
  // SAVE FORM FIELD DATA AS VARIABLES 
  $name = $posted_data["your-name"];
  
  $pdf = new FPDF();
  $pdf-&gt;AddPage();
  $pdf-&gt;SetFont('Arial','B',16);
  $pdf-&gt;Write(5,$name);
  $pdf-&gt;Output(FPDF_PATH.'test.pdf', 'F'); // OUTPUT THE NEW PDF INTO THE SAME   DIRECTORY DEFINED ABOVE
  
  }
  }
  
  add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
  function mycustom_wpcf7_mail_components($components){
  if (empty($components['attachments'])) {
  $components['attachments'] = array(FPDF_PATH .'test.pdf'); // ATTACH THE NEW PDF    THAT WAS SAVED ABOVE
  }
  return $components;
  }
  </code></pre>