How to add a custom message shortcode
Use a custom Event Espresso message shortcode when an email template needs a value that the built-in shortcodes don’t expose. This example adds [SITE_DATETIME_ID] so you can show an event session’s ID in the Registration Approved email.
You’ll need to be able to edit PHP and test a WordPress plugin on a staging site. How to create a site-specific plugin
Find the field and shortcode library
- In Event Espresso → Messages → Default Message Templates, open the Registrant context for Registration Approved.
- Find
[DATETIME_LIST]and open its shortcode picker. Check whether a built-in shortcode already supplies what you need. - Look up a built-in shortcode from the same field in the source. For example,
[DATETIME_START]comes fromEE_Datetime_Shortcodes, which handles each individual datetime in the list. Use that library for the session ID. Message shortcode reference

Register the shortcode and return its value
Add the following to your site-specific plugin inside its existing PHP block. The first filter adds the shortcode and a description to the datetime library. The second filter returns the current datetime ID when it sees that shortcode. For all other input, the callbacks return the original values.
add_filter(
'FHEE__EE_Shortcodes__shortcodes',
static function (array $shortcodes, $library): array {
if ($library instanceof EE_Datetime_Shortcodes) {
$shortcodes['[SITE_DATETIME_ID]'] = 'The ID of the current event datetime.';
}
return $shortcodes;
},
10,
2
);
add_filter(
'FHEE__EE_Shortcodes__parser_after',
static function ($parsed, $shortcode, $data, $extra_data, $library): string {
if (
$shortcode === '[SITE_DATETIME_ID]'
&& $library instanceof EE_Datetime_Shortcodes
&& $data instanceof EE_Datetime
) {
return (string) $data->ID();
}
return (string) $parsed;
},
10,
5
);
For another shortcode, choose a name unique to your site or plugin, check the specific library and data type, and escape the value for where the template will display it. The parser’s data varies with the library and message context. Event Espresso shortcode source
Add the shortcode to the message and test it
- Activate your site-specific plugin on staging. Reopen the template editor and confirm
[SITE_DATETIME_ID]appears in the picker for[DATETIME_LIST]. - Add
[SITE_DATETIME_ID]to the list field where you want the ID to appear. Keep the existing date and time shortcodes, then save the template. - Use an event with multiple dates and make a test registration with an inbox you control. Check that the approval email shows the expected ID for each displayed date and that the built-in shortcodes still render.