Posted: 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:
|
Hi, Yes that gist will put you on the correct path.
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).
If the shortcode is registered into a specific library its available for any message type that uses that library within sections that allow it.
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:
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.
So are you not using the EE4 Promotions system? |
|
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.