Tagged: CONTACT FORM, Subject, subject field, text field
-
AuthorPosts
-
June 21, 2016 at 1:35 pm #651473
hi,
We want to fill the subject line of the e-mail with the text that is inputted by the user in a text field
How can we achieve this?Or even better would be the option to have a standard subject and the custom text (inputted by the user) follows.
subject: Email from contact form [text inputted by used in textfield[Any suggestions?
Regards,
June 23, 2016 at 6:01 am #652486Hey hotspot,
Thank you for using Enfold.
This is possible but we need to see the actual contact page so that we can inspect the fields. You can follow the solution here: https://kriesi.at/support/topic/email-subject-from-contact-form-subject/#post-597621
Best regards,
IsmaelJune 23, 2016 at 8:43 am #652545So if im correct we have to place this code in the fucntions file
add_filter('avf_form_subject','avia_change_mail_subject', 10, 3); function avia_change_mail_subject($subject, $new_post, $form_params) { $subject = urldecode($new_post['avia_3_1']); return $subject; }
and tell what field is to be used to fill the subject field?
and by what field it is the ‘number’ of the field?below the link to our contact form
the field ‘onderwerp’ should be the subject line. it would be nice to be able to set the field name in the code, so when the field moves we dont get a problem.
And we would like to have an extra text set before it ‘the name of the website’.June 28, 2016 at 2:57 am #654023Hi,
Use this to fetch the value of the “Onderwerp” field and use it as the email’s subject line.
add_filter('avf_form_subject','avia_change_mail_subject', 10, 3); function avia_change_mail_subject($subject, $new_post, $form_params) { $subject = urldecode($new_post['avia_4_1']); return $subject; }
If you want to know which “number” (ex: avia_4_1) to use in case you adjust the contact form, inspect the field by using any browser’s element inspector. Look for the input field’s name attribute.
Best regards,
IsmaelAugust 2, 2016 at 1:42 pm #667628Hi Ismael,
We also want to add a piece of static text in the subject line, so the subject would look something like this: “e-mailform – onderwerp-field-content”.
Any suggestions on how to add that in your code?
August 6, 2016 at 7:34 am #669248Hi,
This should work:
add_filter('avf_form_subject','avia_change_mail_subject', 10, 3); function avia_change_mail_subject($subject, $new_post, $form_params) { $subject = 'e-mailform - ' . urldecode($new_post['4_1']); return $subject; }
Best regards,
IsmaelAugust 8, 2016 at 11:27 am #669750Hi Ismael,
The code is not working properly it seems.
The content from the ‘avia_4_1’ field, or any other field is not placed in the subject. The text addition ‘e-mailform – ‘ is placed.
Any ideas what might cause the content from the field not being processed?August 12, 2016 at 1:25 am #671595August 12, 2016 at 9:26 am #671768Hi Ismael,
The code above is the same:
add_filter('avf_form_subject','avia_change_mail_subject', 10, 3); function avia_change_mail_subject($subject, $new_post, $form_params) { $subject = 'e-mailform - ' . urldecode($new_post['4_1']); return $subject; }
Can you paste the modified code here please.
August 16, 2016 at 5:48 am #672987Hi,
It’s not the same. Check the following line:
$subject = 'e-mailform - ' . urldecode($new_post['4_1']);
Best regards,
IsmaelAugust 16, 2016 at 8:38 am #673060That worked like a charm, thanks!!!!
August 17, 2016 at 6:58 am #673526December 16, 2016 at 3:07 pm #725348Hi Guys,
An additional question or maybe a bug.
I placed another contact form in the same page, this form doesn not neccessarily need to have the subject line filled in this way.
But this extra form does not seem to work when we test it. We hit the send button and the form closes, but the thatnk you message is not displayer, nor do we receive the email.Any ideas what might be causing this?
Love to hear from you.
December 17, 2016 at 10:18 am #725663December 17, 2016 at 12:34 pm #725683Hi Ismael, what do you mean?
we have 2 form ons the page, both work and sent email.
– The first form has the subject field automatically populated with the code you supplied.
– The second form we need to function in the default way. Or also be able to have the subject line automatically populated with the content of a specific field.Any suggestions how to ahieve this?
December 22, 2016 at 4:05 am #727363Hi,
I’m sorry but the filter will affect every contact form in the page. You have to put the second contact form in another page then add the is_page conditional function or remove the filter in the functions.php file altogether.
Best regards,
IsmaelDecember 22, 2016 at 10:36 am #727470Hi Ismael,
Thanks for your help.yigit is helping out on another thread about this:
Hopefully he can figure out how to get this to work.
thanksDecember 28, 2016 at 3:18 am #728337Hi,
I see. Please adjust the code in the functions.php file a bit.
add_filter('avf_form_subject','avia_change_mail_subject', 10, 3); function avia_change_mail_subject($subject, $new_post, $form_params) { if ($form_params['avia_formID'] == 1) { $subject = urldecode($new_post['avia_4_1']); } else { $subject = $subject; } return $subject; }
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.