Notice: WC_Cart::get_cart_url is deprecated since version 2.5! Use wc_get_cart_url instead. in /home/wordpre2/public_html/wp-includes/functions.php on line 3831
Select Page

If you are using Divi wordpress theme, to build custom layouts for your wordpress posts, pages or projects, and use the Contact form Module to each of the post or project, you will notice that the subject of the email you will recieve is not to good.

Let’s just think that you have an affiliate website like this one, when for each theme (project) you want to have this Cotact Form module which can be use if someone will ask you for a particular topic. For example, I put on my website some of the themes that Elegat Themes offers, and for each theme at the bottom I have a contact form.

I want when someone will use a contact form from any theme, the email subject I will receive to be: Customization request for {project_name}. A more relevan example will be:
Joe Doe, will find this project called Divi WordPress theme and he will fill out the contact form to ask for a customization support. My email which I will receive from Joe Doe, will have the subject: Customization request for Divi WordPress theme, which is the actual title for this particular project.

To do that, we will need to edit/modify the function.php file. First make sure to backup this file, open it in your favorit text editor and go to line 2115 or search for $et_site_name = get_option( 'blogname' );. You can delete this line or you can leave it. After this line add this line of code:

  
    $post_name = get_the_title( $post->ID );
  

Next replace this block of code (line 2124):

  
wp_mail( apply_filters( 'et_contact_page_email_to', $et_email_to ),
      sprintf( __( 'Customization Request for %1$s%2$s', 'Divi' ),
        sanitize_text_field( $et_site_name ),
        ( '' !== $title ? sprintf( _x( ' - %s', 'contact form title separator', 'Divi' ), sanitize_text_field( $title ) ) : '' )
      ), stripslashes( wp_strip_all_tags( $POST['et_pb_contact_message'] ) ), apply_filters( 'et_contact_page_headers', $headers, $contact_name, $contact_email ) );

  

with this:

  
    wp_mail( apply_filters( 'et_contact_page_email_to', $et_email_to ),
      sprintf( __( 'Customization request for %1$s', 'Divi' ),
        sanitize_text_field( $post_name )), stripslashes( wp_strip_all_tags( $POST['et_pb_contact_message'] ) ), apply_filters( 'et_contact_page_headers', $headers, $contact_name, $contact_email ) );
  
Make sure to replace the php variable $POST in the above code blocks with the correct one: $ _ POST but with no spaces. I had to make that change because in some wired way wordpress tried to execute that php code.

Examples

Example Inbox
Example Inbox

Example Email
Example Email

Save the file and uploaded to your server.
Now when someone will use the Divi Contact Form Module, which you have place it on a post, page or project, the email subject you will receive will be the post / page / project title.

About author

Young and dedicated fellow, which has playing with WordPress for 5 years now, likes everything about web design and web development.

View all author posts →

Share This