• Danielle

    (@secretfamiliesmc)


    I haven’t updated Contact Form 7 since last year because I was having such a hard time figuring out how to change my functions. Can someone please assist? I am trying to dynamically attach a file based on the team type selected on my form. This is my old code in functions.php:

    function wpcf7_attach_instructions(&$WPCF7_Form) {
    //check if it is the Team Sign Up form
    if (($WPCF7_Form->id==405) or ($WPCF7_Form->id==470))
    {
    // get the dropdown menu value and the corresponding instruction file
    $myDocName = $WPCF7_Form->posted_data[‘TeamType’].”.pdf”;
    $WPCF7_Form->mail_2[‘attachments’] = “uploads/Instructions/”.$myDocName ;
    If ($WPCF7_Form->id==405) {
    // attach team sign up sheet
    $WPCF7_Form->mail_2[‘attachments’] .= “\nuploads/Instructions/TeamSignUp.pdf”;
    }
    error_log(“***********WRITTING TO LOG *******************”);
    error_log($WPCF7_Form->mail_2[‘attachments’]);
    }
    }
    add_action(“wpcf7_before_send_mail”,”wpcf7_attach_instructions”);

    Thank you in advance.

    https://www.secretfamiliesmc.org

    https://www.ads-software.com/plugins/contact-form-7/

  • The topic ‘Need help getting files dynamically attached’ is closed to new replies.