-
AuthorPosts
-
December 13, 2014 at 10:32 pm #367788
Hi,
It looks like when I add a Contact Form using the Advanced Layout Editor, and select Contact Form from the Content Elements, I run into a very specific problem.
By default, if you have an item and validate it as an email address, it automatically puts the email address in the from field of the email that is generated. That’s great! BUT, not if your email address is a gmail.com address or some other address handled by Google (or AOL or Yahoo).
The reason is that most emails will get through but emails sent from people with addresses that end in gmail.com, yahoo.com, and aol.com will not get through the form.
Why? Because of the DMARC policy thing they implemented early this year. Bottom line is that if you fill out a form on my site and use an AOL address as your email address I won’t get it.
I’ve seen a solution with other form scripts where instead of using the person filling out the form’s email address as the From, the From is set to the default email address on the server. And, as a bonus, the Reply-To is set to the person filling out the form’s email address. That way emails get to me, but in my email program if I hit reply, my email gets sent to the person who filled out the form and not just to the default email address.
Is there a similar work around here?
If so how do I implement it?
December 13, 2014 at 11:05 pm #367800Hey!
Try adding this at the very end of your theme / child theme functions.php file:
function change_cf_from() { return " (Email address hidden if logged out) "; } add_filter('avf_form_from', 'change_cf_from', 10);
Cheers!
JosueFebruary 20, 2015 at 9:31 pm #399886That works. Is there a way to set the Reply-To header to the email address of the visitor who filled out the form. That way even though the From field gets through the DMARC issues, if I hit reply in my email program the response goes to the right person instead of the generic email address I’m using to send from the server?
February 21, 2015 at 4:26 am #399984Try with this:
add_filter('avf_form_mail_header', 'chang_reply_to', 10, 3); function chang_reply_to($header, $new_post, $form_params){ $header .= 'Reply-To: ' . $new_post['email'] . "\r\n"; return $header; }
Best regards,
JosueApril 14, 2015 at 9:06 pm #428462Hi – I know it is a while but just picked this up again and it doesn’t seem to be working. The first bit of code changes the from address – so that works!
But, the second bit of code doesn’t seem to work. When I hit reply I get an empty To field instead of the value in the Email field.
Help!
And thanks in advance!
April 15, 2015 at 2:30 am #428615Hm, let’s discard something, change the last code to:
add_filter('avf_form_mail_header', 'chang_reply_to', 10, 3); function chang_reply_to($header, $new_post, $form_params){ $header .= "Reply-To: (Email address hidden if logged out) \r\n"; return $header; }
Now check if ” (Email address hidden if logged out) ” appears when you hit the reply button.
Regards,
JosueApril 15, 2015 at 2:40 am #428617That worked. So how do we get it to be the value entered in the Email field in the form instead of (Email address hidden if logged out) ?
April 15, 2015 at 3:20 am #428627Open js/shortcodes.js and comment/remove this line (98):
$('.avia_ajax_form', container).avia_ajax_form();
Then change back the code in functions.php to:
add_filter('avf_form_mail_header', 'chang_reply_to', 10, 3); function chang_reply_to($header, $new_post, $form_params){ $header .= 'Reply-To: ' . $new_post['email'] . "\r\n"; return $header; }
And check if it works now.
Regards,
JosueApril 15, 2015 at 3:48 am #428637Didn’t work. Now when I hit reply, it replies to the from address – it is not picking up the email address as the reply-to address.
The field in the form I am using for the email address is labeled Email when I build the forms in case that matters.
Do you want me to send you credentials for the site or anything else?
April 15, 2015 at 3:52 am #428638Also, I didn’t modify the shortcodes.js in the enfold theme. Instead I added a js folder in my child theme and dropped in shortcodes.js there and modified that. I think that should work – but maybe not. Didn’t want to modify the enfold theme directly.
April 15, 2015 at 4:45 am #428660No, that won’t work unless you add this to your child theme functions.php:
function change_shortcodesjs() { wp_dequeue_script( 'avia-shortcodes' ); wp_enqueue_script( 'avia-shortcodes-child', get_stylesheet_directory_uri().'/js/shortcodes.js', array('jquery'), 2, true ); } add_action( 'wp_enqueue_scripts', 'change_shortcodesjs', 100 );
However, i’d suggest doing the change in the parent theme and check if it works first.
Best regards,
JosueApril 15, 2015 at 1:02 pm #428882Still sending the email to the from address not a reply-to address even with commenting out the line in the js file in the parent theme.
April 15, 2015 at 5:36 pm #429089Hi,
Can you please create me a WordPress administrator account? post it here as a private reply.
Regards,
JosueApril 16, 2015 at 11:48 am #429527This reply has been marked as private.April 16, 2015 at 10:07 pm #429937Hey,
Should work now, try it. I’ve changed the code to:
add_filter('avf_form_mail_header', 'chang_reply_to', 10, 3); function chang_reply_to($header, $new_post, $form_params){ $header .= 'Reply-To: ' . $new_post['email_1'] . "\r\n"; return $header; }
Best regards,
JosueApril 20, 2015 at 9:11 pm #431600It did – thanks!
April 20, 2015 at 10:36 pm #431634I spoke too soon. I just updated the theme from version 3.04 (I think) to the latest version. Now instead of the email in the reply-to looking like:
(Email address hidden if logged out)
it looks like:
(Email address hidden if logged out)Please help!
Thanks in advance!
April 21, 2015 at 12:04 am #431673April 21, 2015 at 4:34 pm #432109Removing the line in the parent shortcodes.js file did the trick – thanks!
April 21, 2015 at 7:19 pm #432288Hi,
Glad it worked, i’d suggest trying to implement it on the child theme to avoid losing it when updating.
Cheers!
Josue -
AuthorPosts
- You must be logged in to reply to this topic.