Skip to content

Instantly share code, notes, and snippets.

@jonahcoyote
Last active December 14, 2015 04:59
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 jonahcoyote/5032062 to your computer and use it in GitHub Desktop.
Save jonahcoyote/5032062 to your computer and use it in GitHub Desktop.
The Events Calendar - Auto Set Meta on Facebook Import
<?php
function tribe_enable_map_on_imported_events( $post_id ) {
// stop if args aren't set or we're not dealing with an event
if (! isset($post_id) && ! get_post_type($post_id) == 'tribe_events') {
return;
}
// get the field Tribe sets for event source
$mrw_event_origin = get_post_meta( $post_id, '_EventOrigin', true );
// if source is facebook and this isn't a revision, set a category for the post
if( $mrw_event_origin == 'facebook-importer' && !wp_is_post_revision( $post_id ) ) {
// set show map to checked
update_post_meta($post_id, '_EventShowMap', true);
}
}
add_action( 'tribe_events_event_save', 'tribe_enable_map_on_imported_events' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment