Title: WordPress shortcode in email data (Feature request, patch included)
Last modified: August 20, 2016

---

# WordPress shortcode in email data (Feature request, patch included)

 *  [jrblast](https://wordpress.org/support/users/jrblast/)
 * (@jrblast)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/wordpress-shortcode-in-email-data-feature-request-patch-included/)
 * Hey,
 * I’ve run into a situation where I would like to be able to use wordpress shortcode
   in the email template (subject and body). I’ve made a quick change in my copy
   of the plugin, but thought others might like this as well. I’ve included the 
   patch below. I’m not sure if there’s a better place to do the shortcode, but 
   this seemed logical to me.
 * Edit: I just realized this might not be the right place to submit this since 
   it’s a “support” forum, but I’m not really sure where this would belong.
 *     ```
       Index: includes/classes.php
       ===================================================================
       --- includes/classes.php	(revision 684892)
       +++ includes/classes.php	(working copy)
       @@ -546,6 +546,9 @@
        		if ( $additional_headers )
        			$headers .= $additional_headers . "\n";
   
       +                $subject = do_shortcode( $subject);
       +                $body = do_shortcode( $body );
       +
        		if ( $send )
        			return @wp_mail( $recipient, $subject, $body, $headers, $attachments );
   
       @@ -851,4 +854,4 @@
        	return implode( ' ', $classes );
        }
   
       -?>
       \ No newline at end of file
       +?>
       ```
   
 * [http://wordpress.org/extend/plugins/contact-form-7/](http://wordpress.org/extend/plugins/contact-form-7/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [clairenooga](https://wordpress.org/support/users/clairenooga/)
 * (@clairenooga)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/wordpress-shortcode-in-email-data-feature-request-patch-included/#post-3581489)
 * Hi, where do you put this? In which file? Thanks
 *  Thread Starter [jrblast](https://wordpress.org/support/users/jrblast/)
 * (@jrblast)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/wordpress-shortcode-in-email-data-feature-request-patch-included/#post-3581492)
 * This goes in the file includes/classes.php as you can see in the diff.
 * I’m starting to think the lines I added should actually be placed before the 
   CF7 shortcodes are evaluate though, because then a user might have shortcode 
   in their input which would get evaluated. This probably wouldn’t be a security
   concern, but might cause some unexpected results. Just add the lines a little
   earlier, but I don’t remember how much and don’t have the files on this computer
   to check.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WordPress shortcode in email data (Feature request, patch included)’ 
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/)

 * 2 replies
 * 2 participants
 * Last reply from: [jrblast](https://wordpress.org/support/users/jrblast/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/wordpress-shortcode-in-email-data-feature-request-patch-included/#post-3581492)
 * Status: not a support question