Posted: November 12, 2015 at 7:00 pm
|
Hi, I am using ACF to create a custom field for all events. I want this to show in the Main Content for the ticket message. Now, because it’s an array using a repeater field, using the [EVENT_META_*] wouldn’t work as it needs to be formatted correctly. I understand I need to use the FHEE__EE_Shortcodes__shortcodes and FHEE__EE_Shortcodes__parser_after filters, but can only find the example relating to the DateTime List. If I can get an example that allows me to work with the Event ID, I can go from there. Cheers |
Hi Deanna, You can view a previous discussion on adding EE Message shortcodes here: https://eventespresso.com/topic/venue-against-each-date/#post-177488 Is that where you saw the example you mentioned above? Within both of those functions you basically add a check for EE_Event_Shortcodes in the same way EE_Datetime_Shortcodes is checked. I’ve updated my gist that provided an example of adding shortcodes to the EE message system to include a check for EE_Event_Shortcodes and add another shortcode to that. You do not need to add shortcodes to the Datetime section if you don’t need them, they can just be removed from the function. Here is a link to view the code: https://gist.github.com/Pebblo/e87cc8e30c4848dcdfe2 $data is library specific, so when in EE_Datetime_Shortcodes $data is an EE Datetime, when in EE_Event_Shortcodes $data is an EE Event. All I am doing is passing back the ID’s for both in this example. Does that help? |
|
|
Hi Tony, It looks like that will do the trick. I’ll give it a go. Thanks! |
You’re most welcome ๐ |
|
|
Hi again Tony, When I copy your code from the gist and use both shortcodes in their appropriate areas, I see a number returned for DateTime (1 in this case) but nothing for [TONYS_EVENT_SHORTCODE]. I am supposing to see the post id for that event. Cheers |
Yes it should return the ID of the event. [TONYS_EVENT_SHORTCODE] should be used within the event list, are you using it there? |
|
|
Yep, i see it in the list of other shortcodes from the selector and place it correctly. |
I’m not sure why that wouldn’t work. I place the code within Event_list – http://take.ms/qTEzQ Then within preview – http://take.ms/7eOmE It also works as expected within the emails themselves. Are you using the latest version of EE? Is you event published? Try swapping out line 42 of the gist:
For something like:
Then retry and see if the string is output. |
|
|
Tony, as mentioned in the first message, I would like to use this within the ticket html, not a standard registration email. Am assuming this changes things… the date time one seems to work. |
Ah, apologies it does change things. The ticket messenger does not pass the EE_Event object as $data, it passes a EE_Messages_Addressee object, which you then need to use to pull the primary registration and then the event from that. Updated my gist with an example. |
|
|
Thanks for that Tony, that does the trick. |
You’re most welcome ๐ |
|
The support post ‘Custom Shortcode for the Main Content Messages.’ 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.