Support

Account

Home Forums ACF PRO Send dynamic pdf with CF7 Reply To: Send dynamic pdf with CF7

  • I’ve done some dynamic population in CF7, but it’s not easy because there’s not much documentation on doing this type of thing.

    It appears that you could add attachments by adding a filter for the hook wpcf7_mail_components. This is called on line 61 of contact-form-7/includes/mail.php

    You might be able to add additional attachments here, but then the question becomes what post is the form being submitted for so that you can figure out what attachments to add? Will any of the other values passed by the filter help you figure that out.

    I would start by disabling JavaScript, basically so that I can submit the form without AJAX and be able to see what’s going on and then I’d add the following into my functions.php file.

    
    <?php  
      add_filter('wpcf7_mail_components', 
        'my_wpcf7_mail_components_filter', 10, 3);
      function my_wpcf7_mail_components_filter($components, $form, $object) {
        var_dump($components, $form, $object);
        die;
      }
    ?>
    

    Then I’d submit a form and see what happens and hope I see some way to figure out the post ID so I can get the attachment from the ACF field and return it.

    Not sure this will help you, but it might get you started.