Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1409053

    Hello, is it possible to have the name and surname of the person filling in the form appear in the reply email?

    Thank you

    #1409088

    Hey cadra83,

    Thank you for the inquiry.

    Yes, it is possible to achieve that using the avf_contact_form_autoresponder_mail filter. You can add the following code snippet to your functions.php file:

    add_filter("avf_contact_form_autoresponder_mail", function($mail_array, $new_post, $form_params, $class) { 
         $mail_array["Subject"] = "Hello " . $new_post["2_1"];
    
         return $mail_array;
    }, 10, 4);
    

    In the code, $new_post[“2_1”] represents the value of the second input field in the form. If you want to use a different field, make sure to replace “2_1” with the ID of the appropriate input field. For example, if the name field is the third field in the form, you would replace “2_1” with “3_1”.

    By adding this code to your functions.php file, the subject of the autoresponder email will be modified accordingly.

    Best regards,
    Ismael

    #1409094

    Good morning, thank you for your reply! I have tested the code and I would say we are on the right track.

    I tried changing Subjet to Textarea, to have the response data within the email and not the subject.

    This works but I no longer see the remaining fields entered.

    Is it possible to make it so that first name and last name are present at the beginning of the textarea field,

    HELLO MARCO MARCON … and then the data for the fields?

    Thank you

    #1409244

    Hi,

    Thank you for the update.

    What do you mean by “tried changing Subject to Textarea”? Please post the modified code here so that we can check it and provide a link to the page containing the contact form so that we can see the position of the input fields. The modification above should not have affected the email message.

    Best regards,
    Ismael

    #1409251

    Goodmorning!

    This is my code test:

    add_filter(“avf_contact_form_autoresponder_mail”, function($mail_array, $new_post, $form_params, $class) {
    $mail_array[“Textarea“] = “Hello ” . $new_post[“2_1”];

    return $mail_array;
    }, 10, 4);

    I have replaced SUBJECT with TEXAREA!

    here is the link with the contact form https://www.christianbardus.it/

    Thank you

    #1409363

    Hi,

    Thank you for following up.

    You shouldn’t adjust the key name in the $mail_array. Please revert it back to the to subject, and adjust the $new_post key instead.

    add_filter("avf_contact_form_autoresponder_mail", function($mail_array, $new_post, $form_params, $class) { 
         $mail_array["Subject"] = "Hello " . $new_post["1_1"] . " " . $new_post["2_1"] . "!";
    
         return $mail_array;
    }, 10, 4);
    

    Best regards,
    Ismael

    #1409400

    Thank you very much, I think we are almost there. I wanted it to appear before the text message and not in the subject field, as per the picture. Then I’d say we’re there.

    Thank you for your helpfulness!
    IMAGE

    #1409723

    Hi,

    To make the name appear before the email message, please replace the filter with the following code.

    add_filter("avf_contact_form_autoresponder_mail", function($mail_array, $new_post, $form_params, $class) { 
         $mail_array["Message"] = "Hello " . $new_post["1_1"] . " " . $new_post["2_1"] . "!\n" . $mail_array["Message"];
    
         return $mail_array;
    }, 10, 4);

    Thank you for your patience.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.