Support

Home Forums Event Espresso Premium Custom Shortcode for the Main Content Messages.

Custom Shortcode for the Main Content Messages.

Posted: November 12, 2015 at 7:00 pm

Viewing 11 reply threads


dcorso

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


Tony

  • Support Staff

November 13, 2015 at 3:28 am

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?


dcorso

November 13, 2015 at 3:37 am

Hi Tony,

It looks like that will do the trick. I’ll give it a go. Thanks!


Tony

  • Support Staff

November 13, 2015 at 3:40 am

You’re most welcome ๐Ÿ™‚


dcorso

November 13, 2015 at 5:25 am

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


Tony

  • Support Staff

November 13, 2015 at 5:46 am

Yes it should return the ID of the event.

[TONYS_EVENT_SHORTCODE] should be used within the event list, are you using it there?


dcorso

November 13, 2015 at 6:30 am

Yep, i see it in the list of other shortcodes from the selector and place it correctly.


Tony

  • Support Staff

November 13, 2015 at 6:50 am

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:

return $data->ID();

For something like:

return "My Custom String";

Then retry and see if the string is output.


dcorso

November 13, 2015 at 6:59 am

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.


Tony

  • Support Staff

November 13, 2015 at 7:27 am

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.

https://gist.github.com/Pebblo/e87cc8e30c4848dcdfe2


dcorso

November 15, 2015 at 4:16 am

Thanks for that Tony, that does the trick.


Tony

  • Support Staff

November 16, 2015 at 4:22 am

You’re most welcome ๐Ÿ™‚

Viewing 11 reply threads

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.

Event Espresso