A custom special mail-tag can add a server-controlled workflow label to a Contact Form 7 notification without asking visitors to supply it. A support team might want a fixed queue code next to the normal inquiry details. The useful distinction is ownership: the server chooses the label from an approved map, while submitted answers remain ordinary mail-tags.

This guide uses the wpcf7_special_mail_tags filter for a plain text label. It does not route mail, create a unique submission ID or add a CRM integration. For the standard built-in values, first check the special mail-tags reference; custom code is unnecessary when an existing tag answers the question.
Define the label and the forms allowed to use it
Choose a unique tag name, such as [_example_workflow_label], and one documented meaning. In this example, it describes a fixed operational queue. It is not a legal classification, customer entitlement or destination address. Keep it in the message body initially, where a formatting mistake is easier to notice and less likely to disrupt delivery.
Record the numeric WordPress record ID of each permitted CF7 form from its administration screen. The sample map uses 123 only as an illustration: replace it with the intended record ID. Do not confuse an internal record ID with a page ID or assume that every shortcode identifier has the same representation.
Understand how the filter receives its value
The current CF7 mail replacement source passes the existing replacement, tag name, HTML-context flag and mail-tag object to this filter. Its built-in special-tag handlers return the incoming value when they do not handle a name. Follow that cooperative pattern so your callback does not erase another extension’s work.
WordPress filter registration also needs an accepted-argument count that matches the callback. The example accepts three arguments because it needs only the replacement, name and HTML flag. It deliberately leaves the fourth argument unused.
Add a narrow callback in a site plugin
Place the following PHP inside a reviewed site plugin on staging. If the plugin already begins with an opening PHP tag, do not add a second one. Keep a copy of the approved form-ID map with the release notes. The code is an illustrative implementation for version-specific review, not a report of testing against your installation.
add_filter( 'wpcf7_special_mail_tags', function ( $output, $name, $html ) {
if ( '_example_workflow_label' !== $name || null !== $output ) {
return $output;
}
$submission = WPCF7_Submission::get_instance();
if ( ! $submission ) {
return $output;
}
$form = $submission->get_contact_form();
$labels = array(
'123' => 'General inquiries & quotations',
);
$id = (string) $form->id();
if ( ! isset( $labels[ $id ] ) ) {
return '';
}
return $html ? esc_html( $labels[ $id ] ) : $labels[ $id ];
}, 20, 3 );
The callback ignores every other name and preserves a replacement already supplied by an earlier filter. For the target tag on an unmapped form, it intentionally returns an empty string. That is the chosen fallback, not a claim that the inquiry reached a queue. If a blank label is operationally unacceptable, the release checklist must catch the missing mapping before launch.
The ampersand demonstrates why HTML and plain text contexts differ. The callback escapes the label for HTML output and returns plain text otherwise. Keep this label out of recipient and header fields; designing safe dynamic addressing is a separate task. Avoid fetching a label from an external API during email composition.
Add the mail-tag to the intended message body
In the selected form’s Mail tab, add a clearly labeled line beside the existing inquiry details:
Workflow: [_example_workflow_label]
A special mail-tag has no matching form control, so adding an input with that name is unnecessary. Check the Form versus Mail mapping guide if the editor warns about a different ordinary tag. Preserve the sender, recipient and Reply-To configuration while testing this body-only change.
Mail (2) has its own template. If enabled, decide explicitly whether its recipient should see an internal queue label. Leaving the tag out of the autoresponder is often the clearer choice. If you include it, inspect that captured message independently; successful output in the main notification is not proof that every template is correct.
Run a small, isolated verification matrix
- Mapped form, plain text mail: the expected readable label appears once.
- Mapped form, HTML mail: the ampersand is displayed correctly, without raw entities or injected markup.
- Unmapped form containing the tag: the documented empty fallback appears, and ordinary fields remain unchanged.
- Unrelated built-in and custom mail-tags: their values still render as before.
- Mail (2), when enabled: only the deliberately chosen information appears.
Use synthetic inquiries and an isolated email testing setup. Do not send test notifications to real customers. Compare the captured message body with the expected text, then verify an unrelated form to catch accidental global replacement.
Keep the workflow label separate from delivery evidence
A label in an email only proves that the composition path produced that label in the observed test. It does not prove CRM acceptance, a human response or inbox placement. If another system needs the same queue code, map it explicitly in the connector and verify the actual payload. Mail composition does not automatically extend every storage or webhook plugin.
When forms move between environments, numeric IDs can differ. Update the map during migration and retain the old approved plugin version for a focused rollback. Never infer production mappings from a staging shortcode. For aggregate submission trends, use Svetlik Analytics for Contact Form 7, our free plugin, alongside the separate delivery and lead-handling checks your workflow requires.
