-
AuthorPosts
-
May 30, 2023 at 8:15 pm #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
May 31, 2023 at 5:12 am #1409088Hey 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,
IsmaelMay 31, 2023 at 8:03 am #1409094Good 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
June 1, 2023 at 4:52 am #1409244Hi,
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,
IsmaelJune 1, 2023 at 7:48 am #1409251Goodmorning!
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
June 2, 2023 at 7:45 am #1409363Hi,
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,
IsmaelJune 2, 2023 at 1:53 pm #1409400Thank 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!
June 6, 2023 at 4:08 am #1409723Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.