Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Used to generate the mail tags into the message body, blog post explaining how to use this gist: https://hunterwebdev.io/blog/quickly-add-all-contact-form-7-tags-when-creating-form/
var $ = jQuery;
var copy = "\n\n";
var i = 0;
$('#wpcf7-mail .mailtag.code.unused').each(function(){
var text = $(this).text();
var key = text.replace(/\[|]/g, '');
copy += key.replace(/\-|_/g, ' ').toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
}) + ": " + text + "\n";
i++;
});
console.log('Lines Typed: ' + i);
$('#wpcf7-mail-body').val($('#wpcf7-mail-body').val() + copy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.