-
AuthorPosts
-
August 30, 2013 at 1:45 pm #28719
When a visitor sends a message using the contact form, the default subject is “New Message (sent by contact form at ******)” in the mail. Is it possible to change this? I have a field called Subject in the contact form, when a visitor writes a subject of their mail I would like that to be shown instead of the default.
August 30, 2013 at 3:31 pm #138428Agreed maybe this can be a feature added?
August 30, 2013 at 5:33 pm #138429Yes, it would need to be added in as a new feature. You can request it in this topic: https://kriesi.at/support/topic/enfold-feature-requests
Regards,
Devin
August 30, 2013 at 5:42 pm #138430I have suggested it. Thank you.
Is there any other way to change it? So it says just “Message” or something.
August 30, 2013 at 7:02 pm #138431Yes, I’m also interested in changed the mail subject!!!!.
If you can tell us where to find this in code, we don’t have to wait for the next theme release.
Thanks.
August 30, 2013 at 7:12 pm #138432It is found in framework/php/class-form-generator
I just don’t know how to change it.
August 30, 2013 at 7:23 pm #138433Afaik Kriesi already added a filter to the form class which allows you to change the subject without modifying framework/php/class-form-generator.php. You must use Enfold 2.0.x. Insert following code at the bottom of functions.php:
add_filter('avf_form_subject','avia_change_mail_subject', 10, 3);
function avia_change_mail_subject($subject, $new_post, $form_params)
{
$subject = 'My email subject';
return $subject;
}and instead of “My email subject” insert your custom subject text.
Update – I just saw that this filter is not included in the themeforest version of the theme yet but it will be part of the next update. If you want to use it now (with the current Enfold version) replace
$subject = urldecode( $subject . " (".__('sent by contact form at','avia_framework')." ".$myblogname.")" );
with
$subject = urldecode( $subject );
$subject = apply_filters("avf_form_subject", $subject, $new_post, $this->form_params);September 8, 2013 at 9:36 am #138434I see in the update you have added a function to change the contact form subject. Is it possible now to use the contact form subject as the mail subject.
For instance, I have the fields name, e-mail, subject, message. A visitor writes “I want to talk about this and that” in the subject field. I want this to be viewed the mail subject in my mail.
September 9, 2013 at 7:27 am #138435The $new_post array holds the submitted data. Following code
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['subject_'.(avia_form::$form_id - 1)]);
return $subject;
}would set the content of the “subject” field as the mail subject.
September 9, 2013 at 9:28 am #138436Tried your suggestion but I’m getting an empty subject line.
What do you mean by “if your field name is different”?
September 9, 2013 at 3:10 pm #138437I tried this out and I also get an empty subject line on the mail recieved.
September 10, 2013 at 10:57 am #138438I just noticed that Kriesi added a form id to the input fields with the update. I changed the code above to incorporate this change.
The answer to the question “What do you mean by “if your field name is different”?” – Enfold allows you to change the “Form Element Label”
This label text will be used for the form name too. If your “subject” field is not labeled with “subject” the above code will not work. You’d need to replace the word “subject” in
$new_post['subject_'.
with your field label text – i.e. if the field label is “Test” the code would look like
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['test_'.(avia_form::$form_id - 1)]);
return $subject;
} -
AuthorPosts
- The topic ‘Mail subject’ is closed to new replies.