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

    #138428

    Agreed maybe this can be a feature added?

    #138429

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

    #138430

    I have suggested it. Thank you.

    Is there any other way to change it? So it says just “Message” or something.

    #138431

    Yes, 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.

    #138432

    It is found in framework/php/class-form-generator

    I just don’t know how to change it.

    #138433

    Afaik 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);

    #138434

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

    #138435

    The $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.

    #138436

    @Dude,

    Tried your suggestion but I’m getting an empty subject line.

    What do you mean by “if your field name is different”?

    #138437

    I tried this out and I also get an empty subject line on the mail recieved.

    #138438

    I 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;
    }

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Mail subject’ is closed to new replies.