Support » Plugin: Contact Form 7 » little php in e-mail response

  • Resolved simracingmonk

    (@simracingmonk)


    Hi folks,

    I searched 3 days now for a solution of that problem. I hope you can help me – it seems to be so easy -.-

    I want to do a little php script and add the result (string) to the automated email response.

    I managed to add the script and the answer in functions.php:

    add_action( 'wpcf7_before_send_mail', 'wpcf7_add_text_to_mail_body' );
    
     function wpcf7_add_text_to_mail_body($contact_form){
    
         // get mail property
         $mail = $contact_form->prop( 'mail' ); // returns array 
    
         // add content to email body
         $yourcode = "Your code is: ";
         $yourcode .= "HERE SHOULD BE THE VALUE OF A TEXTBOX";
         $mail['body'] .= $yourcode;
    
         // set mail property with changed value(s)
         $contact_form->set_properties( array( 'mail' => $mail ) );
    
     }

    The only problem is: How can I generate the $yourcode out of a textbox of the form? How can I access the fields?
    Imagine the use fills out the data and types “123abc” in the “yourcode”-Box.
    So that to the mail is added: “Your Code is: 123abc”

    Thank you so much…

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘little php in e-mail response’ is closed to new replies.