Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1083022

    Hi, how are you guys? :)
    It’s about contact form. I want to change subject of the message from default “New Message (sent by contact form at ******)” to values from 2 fields (Subject, City). I.e. subject of email should look like this: When is next training – New York

    I’ve found solution how to make it possible with one field:
    https://kriesi.at/support/topic/email-subject-from-contact-form-subject/

    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['3_1']);
    return $subject;
    }

    I don’t want to mess with code by myself, would you be so kind and help me solve this problem? If it makes any easier, contact form fields are: 1) name 2) email 3) subject 4) city
    Thanks!

    #1084902

    Hey elzevir,
    Sorry for the late reply, I tried to create the same contact form as you described and insert the subject field and the city field as the out going email subject line:
    2019-03-30-113401
    and this is what worked for me, Try adding this code to the end of your functions.php file in Appearance > Editor:

     add_filter('avf_form_subject','avia_change_mail_subject', 10, 3);
    function avia_change_mail_subject($subject, $new_post, $form_params) {
    $subject = sprintf("%s %s", $new_post['3_1'], $new_post['4_1']);
    return $subject;
    }

    If it doesn’t work try changing the field numbers in the code.

    Best regards,
    Mike

    #1085373

    Hi, no worries, take your time :)
    Thanks, it’s working now! :) but…
    … instead of space, I’ve got “%20” :( i.e. “New%20York”
    Any suggestions? :P

    #1085790

    Hi,
    Please check that the code doesn’t have any “curly quotes” in it, often this happens when copying the code from an email or if you have an enhanced clipboard, I’m thinking this because I’m getting the correct space on my localhost.
    I adjusted the code here:

     add_filter('avf_form_subject','avia_change_mail_subject', 10, 3);
    function avia_change_mail_subject($subject, $new_post, $form_params) {
    $subject = sprintf('%s %s', $new_post['3_1'], $new_post['4_1']);
    return $subject;
    }

    Please let us know if this helps, otherwise Please include an admin login in the Private Content area so we can be of more assistance.

    Best regards,
    Mike

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