Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Leo

    (@leonardomiguelneto)

    Hi
    sorry for reopening the subject, but where can I select the menu location, i can’t see login/logout anywhere.

    Thanks

    Leo

    (@leonardomiguelneto)

    It does not work for me too.

    Thread Starter 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;
    }
    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;
    }
    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)

    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.

Viewing 6 replies - 1 through 6 (of 6 total)