Home › Forums › Calendar Products › Events Calendar PRO › Custom function on event import
- This topic has 3 replies, 2 voices, and was last updated 8 years, 9 months ago by
Mediengruppe Thüringen.
-
AuthorPosts
-
June 9, 2017 at 1:15 am #1295654
Mediengruppe Thüringen
ParticipantWe’d like to invoke a custom function when the aggregator imports iCal events.
This function should do:– take an id from the iCal document (it’s our venue id from a third party system, where the locations are previously imported from)
– select post_id from wp_postmeta where meta_key like ‘_ourThirdPartyVenueIdThatWeImportedEarlierWithAllImporter’ and meta_value = 1234;
– set this post_id as the _EventVenueID for the event
– import the event with our custom valueIs there a filter point to hook in this functionality?
Or any other/better way to get a relation between location and event, as there’s no location/venue import (for good reason, i see)
-
This topic was modified 8 years, 10 months ago by
Mediengruppe Thüringen.
June 13, 2017 at 8:03 am #1297186Barry
MemberHi Mediengruppe Thüringen, great question!
Before a new event is created, the tribe_aggregator_before_insert_event filter runs and provides an opportunity to modify the arguments used in the creation of the new event post.
Similarly, if it is an existing event which is being updated, the tribe_aggregator_before_update_event filter will run. Callbacks for these hooks can receive not just the event post arguments, but a reference to the aggregator record object which supplies other pieces of information.
Once the post has actually been created (or updated), the tribe_events_update_meta action will fire: by combining either of the earlier hooks with this one you can target events being created or updated by Event Aggregator and you can then potentially do the work you outlined.
Here’s a skeleton of how this might look:
function modify_upserted_ea_event( $event_id ) { // Alter the event according to your needs update_post_meta( $event_id, '_EventVenueID', '123' ); // Unhook remove_action( 'tribe_events_update_meta', 'modify_upserted_ea_event' ); } function listen_for_ea_upserts( $no_change ) { add_action( 'tribe_events_update_meta', 'modify_upserted_ea_event' ); return $no_change; } add_filter( 'tribe_aggregator_before_insert_event', 'listen_for_ea_upserts' ); add_filter( 'tribe_aggregator_before_update_event', 'listen_for_ea_upserts' );I hope that gets you started – and good luck with the project!
July 5, 2017 at 9:35 am #1316329Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
This topic was modified 8 years, 10 months ago by
-
AuthorPosts
- The topic ‘Custom function on event import’ is closed to new replies.
