Support

Account

Home Forums ACF PRO Send dynamic pdf with CF7

Solving

Send dynamic pdf with CF7

  • Hi Guys,

    I’m trying to make something work,

    I made a upload box in ACF for my client, The client wants to upload a (different) PDF to every post and that their customers can fill out a form and the PDF will be emailed to them, or will download when the credentials ar send.

    So far I tried to work with CF7 and ACF to make it work, but I’ m stuck. Does anybody have ideas? Thanks!

  • 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.

  • Hi,

    I honestly don’t know where your going with this. It should be much more simple than this? But I’ve tried all sorts of options.

    Has anyone else got other ideas?

  • Where I’m going with this is that you need to modify CF7 to change the attachment sent with the email. This isn’t something that can be done just by using an ACF filter or function.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Send dynamic pdf with CF7’ is closed to new replies.