Last active
March 17, 2025 21:29
-
-
Save apintocr/1e568ca25ebcabae64a408d6c40cec62 to your computer and use it in GitHub Desktop.
Edit Subject on Divi Contact Form (using add_filter)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Edit Subject on Divi Contact Form (using add_filter) | |
* | |
* Divi contact form does not allow you to change the subject from the interface. | |
* The problem is that on clients like Gmail the messages get threaded/organized under the same item/title. | |
* To solve this we need a unique subject for each new contact. | |
* However, Divi contact module does not have many hooks or filters, only allowing us to change the $headers[] | |
* This would be great if the 'Subject:' was set on that variable, it is not, so we need to ADD a extra 'Subject:' | |
* not an ideal solution, but it works and currently it is the only way to do this without editing the theme files. | |
* | |
* Just add this code to your child-theme functions.php and you are set to go. | |
* You can add extra variable like get_option('blogname') if you want. | |
* | |
* @author António Pinto <[email protected]> | |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | |
* | |
*/ | |
add_filter('et_contact_page_headers', 'edit_divi_contact_form_subject', 10, 3); | |
function edit_divi_contact_form_subject($headers, $contact_name, $contact_email) | |
{ | |
$headers[] = 'Subject: New contact from the website ' . ' (' . $contact_email . ')'; | |
return $headers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This no longer works, Google rejects the email with an error.
I'm now using this code, but it doesn't include the email address, yet:
https://gist.github.com/presswizards/d1fa3e049bfae57db65790a170465387