Advertisement
Guest User

revision tribe events

a guest
Apr 16th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. function tribe_revision_support_me() {
  2.     add_post_type_support( 'tribe_events', 'revisions' );
  3. }
  4. add_action('init', 'tribe_revision_support_me', 0);
  5.  
  6.  
  7. function mrw_tag_imported_events( $post_id, $post ) {
  8.   // stop if args aren't set or we're not dealing with an event
  9.   if (! ( isset($postId) && isset($post->post_type) ) && ! get_post_type($post_id) == 'tribe_events') {
  10.         return;
  11.     }
  12.  
  13.     // get the field Tribe sets for event source
  14.     $mrw_event_origin = get_post_meta( $post_id, '_EventOrigin', true );
  15.    
  16.     // if source is facebook and this isn't a revision, set a category for the post
  17.     if( $mrw_event_origin  == 'facebook-importer' && !wp_is_post_revision( $post_id ) ) {
  18.         // echo "<h1>mrw_event_origin</h1>: " . $mrw_event_origin . " - revision: " .  var_export(wp_is_post_revision($post_id), true) . " - post_id: " . $post_id; die();
  19.  
  20.         // set category to 'community events'
  21.         // wp_set_object_terms( $post_id, 340, 'tribe_events_cat', true );
  22.        
  23.        
  24.  
  25.     }
  26. }
  27. add_action( 'wp_insert_post', 'mrw_tag_imported_events', 11, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement