Tagged: CONTACT FORM, enfold, woocommerce
We are running a woocommerce site on Enfold (selling used machinery). On each product page we have a standard enfold contact form. When the forms come through in email format we want it to include the URL of the page it was sent from (A link to the actual product). Really struggling and appreciate any advice for what I assumed would be a simple task…
Hi Paul!
Thank you for using Enfold.
Please add this in the functions.php file:
add_filter('avf_form_message', 'avf_form_message_mod');
function avf_form_message_mod($message) {
global $post;
$message .= "<br>Page: ".get_the_title($post->ID);
return $message;
}
Best regards,
Ismael
Thanks Ismael, Could you be specific about which Functions.php file. We tried it in the theme and child theme functions PHP file and it broke the site.
Paul
Hey!
Please go to Appearance > Editor and add the code Ismael posted above into functions.php file.
Regards,
Yigit
Thanks Yigit. I’ll try this.
Hi,
Great, please let us know if you should need any more help on the topic.
Thanks,
Rikard
This is great, is there anyway to add the actual URL rather than just the page title?
Hi,
Replace the get_the_title function with the get_the_permalink function.
// https://developer.wordpress.org/reference/functions/get_the_permalink/
Best regards,
Ismael
Hi
My php skils kinda stink
How would I format it to get
Sent from: Page title ?
This would be a good standard function btw.. usually in the websites that I build I put contact forms on every single page.. on the sites where this really matters to me I switched to Gravity Forms almost solely for this reason.. haha.. I should’ve searched a bit more maybe
Hi,
@joax: You need to replace this line within the filter or the snippet above.
$message .= "Page: ".get_the_title($post->ID);
Try to replace it with this code instead.
$message .= "Sent from: " . get_the_title($post->ID);
Best regards,
Ismael
Hi,
You will have to append the links manually to the $message.
$message .= "<a href='https://facebook.com?utm_source=Facebook&utm_medium=Sepet1&utm_campaign=tr-yeni">Facebook></a>";
If you need more assistance, please feel free to open another thread. We will close this one for now.
Best regards,
Ismael