Last active
December 14, 2015 04:59
-
-
Save jonahcoyote/5032062 to your computer and use it in GitHub Desktop.
The Events Calendar - Auto Set Meta on Facebook Import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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