Dynamically send pdf attached to post with contact form 7 [closed]

Try this instead. There was some internal restructuring in CF7 3.9.

add_action('wpcf7_before_send_mail','send_pdf');

function send_pdf( $cf7 ) {
    $id = $cf7->id();
    if ($id==741){
        $submission = WPCF7_Submission::get_instance();
        $submission->add_uploaded_file('pdf', get_template_directory().'/test.pdf');
    }
}

This should work.

Leave a Comment