vendredi 27 mars 2015

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


I'm come from this post : contact form 7


So i do the same exact code :



add_action('wpcf7_before_send_mail', 'my_dynamic_attachments');

function my_dynamic_attachments($cf7) {
$id = $cf7->id();
$upload_dir = wp_upload_dir('2015/03');
if ($id==1326){
$submission = WPCF7_Submission::get_instance();
$data = $submission->get_posted_data();
$pdf = $data['brochures'][0];
//echo $pdf;
$submission->add_uploaded_file('pdf', $upload_dir['path'].'/'.$pdf);
}
}


The problem is if file is sent only i uncomment the "echo". Since he was comment, file not be sent and i don't understand why ...


Have an idea ?


Thanks





Aucun commentaire:

Enregistrer un commentaire