Support

Home Forums Event Espresso Premium Custom shortcode for the 'Registration Approved' message

Custom shortcode for the 'Registration Approved' message

Posted: December 18, 2015 at 7:17 am

Viewing 1 reply thread


tesscoadmin

December 18, 2015 at 7:17 am

I have created a custom process where when a user registers for specific events, promotion codes are automatically created and and assigned to related events (via custom fields). I would like to display those promotion codes in the ‘Registration Approved’ email that is sent when the user registers, as well as in the Invoice that is created. I assume I will need to create a custom shortcode that can be used in a custom message template.

How do I go about creating and registering that shortcode? I’ve found the following post which describes how to do this. Will this take me down the correct path? My questions are:

  1. What data is available in the shortcode?
  2. Does the available data vary depending on the context in which it was used? (e.g email vs invoice)
  3. How can I make my shortcode available as a choice in the menus on the message template editor?


Tony

  • Support Staff

December 18, 2015 at 7:42 am

Hi,

Yes that gist will put you on the correct path.

What data is available in the shortcode?

Its dynamic and depends where you register the the shortcode within.

For example in that gist I register a shortcode within the EE_Datetime_shortcodes library.

if ( $lib instanceof EE_Datetime_Shortcodes ) {
	//Add your shortcode to the add as the key, the value should be a description of the shortcode.
	$shortcodes['[TONYS_DATETIME_SHORTCODE]'] = _('This is Tonys Custom DATETIME Shortcode!');
}

Then within the parser we check for the EE_Datetimes_Shortcodes library and run our shortcode. The data available is relative to the library your working in, EE_Datetime_Shortcodes has EE_Datetime objects available, EE_Event_Shortcodes have EE_Event objects available (within $data).

Does the available data vary depending on the context in which it was used? (e.g email vs invoice)

If the shortcode is registered into a specific library its available for any message type that uses that library within sections that allow it.

How can I make my shortcode available as a choice in the menus on the message template editor?

That’s automatically done for you when you register the shortcode.

The best way to see this is to add that plugin from the gist and see what it does, then register your own shortcode to say the EE_Event_Shortcodes library and add a function to the parser for that shortcode, just return a string:

return 'My Custom String Return, woop!';

Then try looking through the EE4 Printable Tickets Add-on as it adds both its own message type and message shortcodes. That should help understand a little better what is going on.

I have created a custom process where when a user registers for specific events, promotion codes are automatically created and and assigned to related events (via custom fields).

So are you not using the EE4 Promotions system?

Viewing 1 reply thread

The support post ‘Custom shortcode for the 'Registration Approved' message’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso