Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #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,

    #652486

    Hey 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,
    Ismael

    #652545

    So 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’.

    #654023

    Hi,

    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,
    Ismael

    #667628

    Hi 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?

    #669248

    Hi,

    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,
    Ismael

    #669750

    Hi 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?

    #671595

    Hi,

    We modified the code a bit. Please try it again.

    Best regards,
    Ismael

    #671768

    Hi 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.

    #672987

    Hi,

    It’s not the same. Check the following line:

    $subject = 'e-mailform - ' . urldecode($new_post['4_1']);
    

    Best regards,
    Ismael

    #673060

    That worked like a charm, thanks!!!!

    #673526

    Hi,

    Great, glad we could help :-)

    Best regards,
    Rikard

    #725348

    Hi 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.

    #725663

    Hi,

    Is it working when you remove the suggested filter?

    Best regards,
    Ismael

    #725683

    Hi 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?

    #727363

    Hi,

    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,
    Ismael

    #727470

    Hi 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.
    thanks

    #728337

    Hi,

    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

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