Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Created November 13, 2017 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/9f68ab6a4753c91ff42c5ba1f0a00b81 to your computer and use it in GitHub Desktop.
Save cliffordp/9f68ab6a4753c91ff42c5ba1f0a00b81 to your computer and use it in GitHub Desktop.
<?php
/**
* @link https://theeventscalendar.com/support/forums/topic/event-aggregator-event-country-imported-from-facebook-in-wrong-language-2/
*/
add_action( 'tribe_aggregator_before_insert_posts', 'test_listen_for_event_creation' );
add_action( 'tribe_aggregator_after_insert_posts', 'test_stop_listening_for_event_creation' );
function test_listen_for_event_creation() {
add_action( 'tribe_events_venue_created', 'test_translate_venue_country', 10, 2 );
add_action( 'tribe_events_venue_updated', 'test_translate_venue_country', 10, 2 );
}
function test_translate_venue_country( $venue_id, $venue_data ) {
$country_map = array(
'Germany' => 'Deutschland',
'Switzerland' => 'Schweiz',
);
if ( isset( $venue_data['Country'] ) && array_key_exists( $venue_data['Country'], $country_map ) ) {
update_post_meta( $venue_id, '_VenueCountry', $country_map[ $venue_data['Country'] ] );
}
}
function test_stop_listening_for_event_creation() {
remove_action( 'tribe_events_venue_created', 'test_listen_for_event_creation' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment