Add custom variable in Contact Form 7 mail body

Question

I set cookie for my users to know from which source they come to the site and I want when user contact us their message comes with their cookie as well.

So that I created a new shortcode and added in mail section but it mails direct shortcode not its returned value

Code :

function my_shortcode( $atts ) {
   return isset($_COOKIE['my_source']) ? $_COOKIE['my_source'] : '' ;
}
add_shortcode( 'my-source', 'my_shortcode' );

Message body in contact form 7 :

Name : [your-name]
Email : [your-email]
Phone : [form-tel]
My Source : [my-source]

Email I Received :

Name : Mohit Bumb
Email : abcde@gmail.com
Phone : 19191919191
My Source : [my-source]
0
, , Mohit Bumb 2 years 2020-08-18T06:10:45-05:00 0 Answers 55 views 0

Leave an answer

Browse
Browse