If you mean the meta character representing a new line, it’s \n , not /n.
Leo
(@leonardomiguelneto)
secretfamiliesmc hello, sorry for my bad english, please can you tell me if this is how to apply the code? I’m days trying to implement this code without success, my data is acquired in drop-down box.
add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components1' );
function mycustom_wpcf7_mail_components1( $components ) {
$myDocName = $WPCF7_Form->posted_data['Mesfatura'].".pdf";
$components['attachments'] = "uploads/777/".$myDocName ;
return $components;
}
what I want is, with the data from drop-down [‘Mesfatura’] select a pdf attachment with the same name. Already tried hundreds of ways and I can’t find a solution.
I would really appreciate any help you can give me.
Thread Starter
Danielle
(@secretfamiliesmc)
Sorry Leo, my code snippet is above. Actually this code doesn’t work anymore since the last big update to the pluggin. I haven’t figured out how to implement. The pluggin documentation is not made for folks who aren’t coders. I will have to try again this summer to get it working. We haven’t updated to the new plugin on our live site due to the issues.
Leo
(@leonardomiguelneto)
Thanks anyway, but I have to find a solution, I really need a code to attach files dynamically with the data placed in the form.
Leo
(@leonardomiguelneto)
I solved the problem with this code
add_action('wpcf7_before_send_mail', 'wpcf7_update_email_body');
function wpcf7_update_email_body($contact_form) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
/* DEFINE CONSTANT AND GET FPDF CLASSES */
define ('PDF_PATH', 'wp-content/uploads/777/'); // MAKE SURE THIS POINTS TO THE DIRECTORY IN YOUR THEME FOLDER THAT HAS PDF
$posted_data = $submission->get_posted_data();
// FORM FIELD DATA AS VARIABLES
$mes = $posted_data['mes'];
define ('PDF_PATH2', PDF_PATH.$mes.'.pdf');
}
}
add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
function mycustom_wpcf7_mail_components($components){
if (empty($components['attachments'])) {
$components['attachments'] = array( PDF_PATH2 ); // ATTACH THE PDF THAT WAS chosen ABOVE
}
return $components;
}