Reputation: 246
Its possible send contatc form name in email body?
[contact-form-7 id="86" title="Contact form 1"]
I try the Contact Form 7 Dynamic Text Extension — WordPress Plugins, but my form are in modal items, when i click in one, show me the modal, and change the url (add -> ?id=23) but the Dynamic Text Extension only accept this field in reload page not after.
Any help?
thanks
Upvotes: 5
Views: 9337
Reputation: 2121
You can just use cf7 plugin features:
Add hidden field in form template, like [hidden title default:shortcode_attr]
Then use this field [title]
in the mail body.
Works for me.
Upvotes: 2
Reputation: 139
I'm very late to the party (as always) but I also needed to differentiate between instances of the same form. By scouring Stackoverflow and the source code I came up with a solution:
Add this to your functions.php:
add_action( 'wpcf7_init', 'cf7_add_form_title' );
function cf7_add_form_title() {
wpcf7_add_form_tag( 'form_title', 'cf7_add_form_title_handler' );
}
function cf7_add_form_title_handler( $tag ) {
$form = wpcf7_get_current_contact_form();
return $form->shortcode_attr('title');
}
As a hidden form field:
<input type="hidden" name="title" value="[form_title]"/>
And as an email-tag:
[title]
The name can of course be anything.
Upvotes: 0
Reputation: 562
I did something similar with the hidden input field and custom shortcode in functions.php. This might helps too
wpcf7_add_shortcode('hidden', 'wpcf7_sourceurl_shortcode_handler', true);
function wpcf7_sourceurl_shortcode_handler($tag) {
if (!is_array($tag)) return '';
$name = $tag['name'];
if (empty($name)) return '';
$html = '<input type="hidden" name="' . $name . '" value="' . get_the_title() . '" />';
return $html;
}
Then add custom tag in contact form 7
[hidden pageTitle]
In email settings
Page title is: [pageTitle]
Upvotes: 3