Guest User

Untitled

a guest
Jun 27th, 2014
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_action( 'save_post', 'run_when_post_saved');
  2. function run_when_post_saved($post_id)
  3. {
  4.  
  5.     $post = get_post($post_id);
  6.     if($post->post_type=="my-custom-post" && $post->post_status == "publish") {
  7.         if( have_rows("credits") ) {
  8.             //later code
  9.         } else {
  10.             //ADD event
  11.             $eventSettings = array(
  12.                 'post_title'        => 'Event test for '.$post->post_title,
  13.                 'post_name'         => 'vent test for '.$post->post_title,
  14.                 'post_status'       => 'publish',
  15.                 'post_content'      => '',
  16.                 "post_type"         => "tribe_events",
  17.                 "original_post_status"  =>"publish",
  18.                 "post_status"           =>"publish",
  19.                 "hidden_post_visibility"=>"public",
  20.                 "visibility"            =>"public",
  21.                 "EventAllDay"           =>"yes",
  22.                 "EventStartDate"        =>"2012-01-01",
  23.                 "EventStartHour"        =>"12",
  24.                 "EventStartMinute"      =>"00",
  25.                 "EventStartMeridian"    =>"am",
  26.                 "EventEndDate"          =>"2012-01-03",
  27.                 "EventEndHour"          =>"11",
  28.                 "EventEndMinute"        =>"00",
  29.                 "EventEndMeridian"      =>"pm",
  30.                 "is_recurring"          =>"yes",
  31.                 "recurrence[type]"      =>"Every+Month",
  32.                 "recurrence[end-type]"  =>"On",
  33.                 "recurrence[end]"       =>"2014-06-29",
  34.                 "recurrence[end-count]" =>"1",
  35.                 "recurrence[custom-type]"       =>"Daily",
  36.                 "recurrence[custom-interval]"   =>"",
  37.                 "recurrence[custom-type-text]"  =>"",
  38.                 "recurrence[occurrence-count-text]" =>"month",
  39.                 "recurrence[custom-month-number]"   =>"First",
  40.                 "recurrence[custom-month-day]"      =>"1",
  41.                 "recurrence[custom-year-month-number]"  =>"1",
  42.                 "recurrence[custom-year-month-day]"     =>"1",
  43.                 "recurrence[recurrence-description]"    =>"",
  44.                 "EventCost"=>"",
  45.                 "excerpt"=>""
  46.             );
  47.             $event_id = TribeEventsAPI::createEvent($loyerSettings);
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment