Tagged: CONTACT FORM
-
AuthorPosts
-
September 12, 2018 at 3:53 pm #1008993
Hi,
I’m trying to edit part of the email sent via contact form. In particular removing the “false” replies from checkboxes and just showing the “true” ones, preferable with an alternative wording like “yes”. Then I’d like to add one of two breaks to structure the mail manually. If possible I’d like to change the date format as well.
Looking forward to hearing from you.
September 13, 2018 at 7:52 am #1009256Hey tebitrongmbh,
1) Please add this code to your child theme functions.php to remove the “false” replies.
add_filter('avf_form_mail_form_field', 'avia_change_checkbox_form_values', 10, 7); function avia_change_checkbox_form_values($form_field, $new_post, $form_elements, $form_params, $element, $key, $field_value) { if($field_value == 'false') $form_field = ''; return $form_field; }
You also need to patch the enfold/framework/php/class-form-generator.php with a new filter – the modified code can be found here: https://pastebin.com/raw/k4KiZK0z . Simply delete the code in enfold/framework/php/class-form-generator.php and copy the code from https://pastebin.com/raw/k4KiZK0z into the file.
The next theme update should include the patched class-form-generator.php and the child theme code will also work with future updates.
2) You can use this code to replace “true” with “yes”:
add_filter('avf_form_mail_field_values', 'avia_change_checkbox_return_values', 10, 4); function avia_change_checkbox_return_values($value, $new_post, $form_elements, $form_params){ if($value == 'true') $value = 'Yes'; return $value; }
3) These filters should help you adjust the datepicker format.
add_filter('avf_datepicker_dateformat', 'new_date_format'); function new_date_format() { $date_format = "mm / dd / yy"; return $date_format; } add_filter('avf_datepicker_date_placeholder', 'new_date_placeholder'); function new_date_placeholder() { $placeholder = "MM/DD/YY"; return $placeholder; }
You can use the default php date placeholders ( http://php.net/manual/de/function.date.php ) to change the format.
4) To modify the message (i.e. to add line breaks, etc.) you can use this code for the autoresponder e-mail:
function avf_form_autorespondermessage_mod($message) { // modify the content of the $message variable here. i.e. use str_replace() $message = str_replace('TEXT TO BE REPLACED', 'TEXT TO INSERT', $message); return $message; } add_filter('avf_form_autorespondermessage', 'avf_form_autorespondermessage_mod', 10, 1);
and this code for the message you get from the contact form:
add_filter('avf_form_message', 'avf_form_message_mod_checkbox', 10, 3); function avf_form_message_mod_checkbox($message, $new_post, $form_params) { // modify the content of the $message variable here. i.e. use str_replace() $message = str_replace('TEXT TO BE REPLACED', 'TEXT TO INSERT', $message); return $message; }
Best regards,
PeterSeptember 13, 2018 at 9:25 am #1009287Hi Peter,
thanks for your reply. I got the child theme to run but I’m for some reason the same form is suddenly giving me problems and not sending the mail, even though it was working on the parent theme. Funny enough the one on my contact page is working just fine, even with the child theme.
Any idea?
- This reply was modified 6 years, 3 months ago by tebitrongmbh.
September 13, 2018 at 1:16 pm #1009377Hi,
Does it work if you remove the code I provided from the child theme functions.php? If yes this may indicate a syntax error in the code I posted above. If not please check if some other code in your child theme may affect the contact form.
Best regards,
PeterSeptember 14, 2018 at 9:50 am #1009839Hi Peter,
for some strange reason I can only fill in the form once with a successful mail going out. Every additional attempt fails until I clear my browser Cache and restart Chrome. The datepicker format kinda worked for the form itself, but I wouldn’t know how to adjust the format for the date in the email itself. Funny enough its still returning “false” replies, even though “true” is successfully coming through as “yes“.
On point 4. for adding breaks I’m lost.
- This reply was modified 6 years, 3 months ago by tebitrongmbh.
September 17, 2018 at 6:32 am #1010585Hi,
You also need to patch the enfold/framework/php/class-form-generator.php with a new filter – the modified code can be found here: https://pastebin.com/raw/k4KiZK0z . Simply delete the code in enfold/framework/php/class-form-generator.php and copy the code from https://pastebin.com/raw/k4KiZK0z into the file.
Did you modify the file as instructed above? Yes, please post the login details in the private field so that we can test the contact form.
Best regards,
IsmaelSeptember 18, 2018 at 8:57 am #1011146Hi Ismael,
thanks for getting back.
Yes, I have replaced the Code in enfold/framework/php/class-form-generator.php.
Still not really running as expected – hope you can look into it.
Regards.
September 18, 2018 at 10:04 am #1011172Hi,
– The datepicker format kinda worked for the form itself.
Yes it only changes the date format in the form field, not the e-mail data. There’s no real fix for this because the jquery date picker plugin converts the data bac-k to the standard format.– Funny enough its still returning “false” replies, even though “true” is successfully coming through as “yes“.
I created a second form to test this and I couldn’t reproduce the issue. I modified the enfold/framework/php/class-form-generator.php and then tested the checkboxes with the form here: http://bonjour.tt-develop.de/reservierungen/referenten-checkliste.html (form at the bottom). If you i.e. just check the first checkbox the result should beE-Mail: (Email address hidden if logged out) Nachricht: Your Message Test: ja
– for some strange reason I can only fill in the form once with a successful mail going out.
I wasn’t able to reproduce this issue but it sounds like a cache issue.Personally I’d recommend to use a dedicated contact form plugin like Formidable or Contact form 7 for your reservation form. These plugins enable you to style and modify the e-mails and you can also send out nice html e-mails to your customers (for contact form 7 you can use this plugin: https://wordpress.org/plugins/cf7-html-email-template-extension/ ). Our contact form is not intented to be used as complex reservation form and you probably won’t be able to style the e-mail/data user friendly way.
Best regards,
PeterSeptember 18, 2018 at 10:12 am #1011177Thanks Peter.
-
AuthorPosts
- You must be logged in to reply to this topic.