WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Can't add extra message info with $cf7->mail_2['body'].=$message;? (2 posts)

  1. DDT
    Member
    Posted 1 year ago #

    Hi,

    I am trying to get this function to work but the most simple adding som e extra message info isn't working, see last line in the function

    add_action( 'wpcf7_before_send_mail', 'createInvoice');`
    function createInvoice($cf7) {
    //check if this is the right form $cf7 &$wpcf7_data
    //print_r(&$wpcf7_data);
    //echo $cf7->id;
    if ($cf7->id==3235){
    echo "test";
    $uploads = wp_upload_dir();
    //define some constants
    define ('COUPON_UPLOAD_PATH',$uploads['path'].'/coupons');
    // ...
    // ...
    if ($cf7->mail['use_html']==true)
    $nl="<br/>";
    else
    $nl="\n";
    //I omitted all the stuff used to create
    //the pdf file, you have just to know that
    //$pdf_filename contains the filename to attach
    //Let'go to the file attachment!
    //$pdf_filename = "test.pdf";
    //$cf7->uploaded_files = array ( 'invoice' => COUPON_UPLOAD_PATH.'/'.$pdf_filename );

    //append some text to the outgoing email
    $message=$nl.$nl.'Blah blah blah.....'.$nl;
    $message.='So Long, and Thanks for All the Fish!'.$nl;
    $cf7->mail_2['body'].=$message;
    }
    }
    `

    original code found here: http://wordpress.org/support/topic/contact-form-7-sending-attachments-without-user-upload?replies=33

    http://wordpress.org/extend/plugins/contact-form-7/

  2. DDT
    Member
    Posted 1 year ago #

    Ok last part is working but the main part adding a .pdf on the fly isn't working :(
    I am developing with xampp and testing locally.

    When i use
    $cf7->uploaded_files = array ( 'invoice' => COUPON_UPLOAD_PATH.'/test.pdf' );
    i get an email with a unamed .pdf of 0kb and the email message body is empty?

    Any tips?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.