Title: Changing default Message body with function
Last modified: May 5, 2023

---

# Changing default Message body with function

 *  [jodybdesigns](https://wordpress.org/support/users/jodybdesigns/)
 * (@jodybdesigns)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/changing-default-message-body-with-function/)
 * Hello,
   I am working on a multi-site website for my company that has some automatic
   functions happen when a theme is activated to help speed up my workflow. All 
   templates/websites share the same contact form. Each time I create a new site
   and create a new form, I have to repeatedly update the Form and the Message body
   with the content I need. I currently have a function that changes the default
   Form content that works great. However, I cannot modify the default Message body
   for the life of me. All fields come back blank on my end. Here is my current 
   code:
 *     ```wp-block-code
       function mod_contact7_form_content( $template, $prop ) {
         if ( 'form' == $prop ) {
           return implode( '', array(
               '[text* your-name placeholder "Name"]',
               '<div class="row mt-3 mb-3">',
               '<div class="col-12 col-md-6">',
               '[email* your-email placeholder "Email"]',
               '</div>',
               '<div class="col-12 col-md-6 mt-3 mt-lg-0">',
               '[tel* your-phone placeholder "Phone"]',
               '</div>',
               '</div>',
               '[select* options "Choose Option" "Service" "Maintenance" "Installation"]',
               '[textarea your-message x4 class:mt-3 placeholder "Explain Your Issue"]',
               '[submit class:btn-block class:btn-tempstar class:mt-3 "SEND YOUR MESSAGE"]',
           ) );
         } else {
           return $template;
         } 
       }
       add_filter('wpcf7_default_template', 'mod_contact7_form_content', 10, 2);
   
       function mod_contact7_form_body( $template, $prop ) {
         if ( 'mail' == $prop ) {
           $template = array(
               'body' => array (
               'Your contact information is as follows:',
               'Name: [your-name]',
               'Email: [your-email]',
               'Phone: [your-phone]',
               'Needed Request: [options]',
               'Message: [your-message]',
               'Be sure to follow up soon!',
             ) );
         } else {
           return $template;
         } 
       }
       add_filter('wpcf7_default_template', 'mod_contact7_form_body', 10, 2);
       ```
   
 * Can you help with this?
   Thanks

Viewing 1 replies (of 1 total)

 *  [AW](https://wordpress.org/support/users/geykgn/)
 * (@geykgn)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/changing-default-message-body-with-function/#post-16717274)
 * Hi,
   You return nothing for the condition:
 *     ```wp-block-code
       if ( 'mail' == $prop ) {
       ```
   
 * At least you change the assignment lines:
 *     ```wp-block-code
       $template = array(
       ```
   
 * on:
 *     ```wp-block-code
       return array(
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Changing default Message body with function’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [AW](https://wordpress.org/support/users/geykgn/)
 * Last activity: [3 years, 1 month ago](https://wordpress.org/support/topic/changing-default-message-body-with-function/#post-16717274)
 * Status: not resolved