Guest User

Untitled

a guest
Jun 27th, 2014
711
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.     $post = get_post($post_id);
  5.     if($post->post_type=="my-custom-post" && $post->post_status == "publish") {
  6.        //ADD event
  7.         $eventSettings = array(
  8.             'post_title'        => 'Event test for '.$post->post_title,
  9.             'post_name'         => 'vent test for '.$post->post_title,
  10.             'post_status'       => 'publish',
  11.             'post_content'      => '',
  12.             "post_type"         => "tribe_events",
  13.             "original_post_status"  =>"publish",
  14.             "post_status"           =>"publish",
  15.             "hidden_post_visibility"=>"public",
  16.             "visibility"            =>"public",
  17.             "EventAllDay"           =>"yes",
  18.             "EventStartDate"        =>"2012-01-01",
  19.             "EventStartHour"        =>"12",
  20.             "EventStartMinute"      =>"00",
  21.             "EventStartMeridian"    =>"am",
  22.             "EventEndDate"          =>"2012-01-03",
  23.             "EventEndHour"          =>"11",
  24.             "EventEndMinute"        =>"00",
  25.             "EventEndMeridian"      =>"pm",
  26.             "is_recurring"          =>"yes",
  27.             "recurrence[type]"      =>"Every+Month",
  28.             "recurrence[end-type]"  =>"On",
  29.             "recurrence[end]"       =>"2014-06-29",
  30.             "recurrence[end-count]" =>"1",
  31.             "recurrence[custom-type]"       =>"Daily",
  32.             "recurrence[custom-interval]"   =>"",
  33.             "recurrence[custom-type-text]"  =>"",
  34.             "recurrence[occurrence-count-text]" =>"month",
  35.             "recurrence[custom-month-number]"   =>"First",
  36.             "recurrence[custom-month-day]"      =>"1",
  37.             "recurrence[custom-year-month-number]"  =>"1",
  38.             "recurrence[custom-year-month-day]"     =>"1",
  39.             "recurrence[recurrence-description]"    =>"",
  40.             "EventCost"=>"",
  41.             "excerpt"=>""
  42.         );
  43.         $event_id = TribeEventsAPI::createEvent($eventSettings);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment