eo_insert_event
since 1.5
eo_insert_event( $post_data = array(), $event_data = array() )
This functions inserts a post of event type, with data given in the $post_data and event data given in $event_data. Returns the post ID.
Triggers eventorganiser_save_event passing event (post) ID
The event data array can contain
schedule
=> (custom | once | daily | weekly | monthly | yearly) -- specifies the recurrence pattern
schedule_meta
=>
- For monthly schedules,
- (string) BYMONTHDAY=XX to repeat on XXth day of month, e.g. BYMONTHDAY=01 to repeat on the first of every month.
- (string) BYDAY=ND. N= 1|2|3|4|-1 (first, second, third, fourth, last). D is day of week SU|MO|TU|WE|TH|FR|SA. E.g. BYDAY=2TU (repeat on second tuesday)
- For weekly schedules,
- (array) Days to repeat on: (SU,MO,TU,WE,TH,FR,SA). e.g. set to array('SU','TU') to repeat on Tuesdays & Sundays.
- Can be left blank to repeat weekly from the start date.
frequency
=> (int) positive integer, sets frequency of recurrence (every 2 days, or every 3 days etc)
all_day
=> 1 if its an all day event, 0 if not
start
=> start date (of first occurrence) as a datetime object
end
=> end date (of first occurrence) as a datetime object
until
=> START date of last occurrence (or upper-bound thereof) as a datetime object
schedule_last
=> Alias of until. Deprecated 2.13.0, use until.
number_occurrences
=> Instead of specifying until
you can specify the number of occurrence a recurring event should have.
This is only used if until
is not, and for daily, weekly, monthly or yearly recurring events.
include
=> array of datetime objects to include in the schedule
exclude
=> array of datetime objects to exclude in the schedule
Example
The following example creates an event which starts on the 3rd December 2012 15:00 and ends on the 4th December 15:00 and repeats every 4 days until the 25th December (So the last occurrence actually ends on the 23rd).
$event_data = array(
'start' => new DateTime('2012-12-03 15:00', eo_get_blog_timezone() ),
'end' => new DateTime('2012-12-04 15:00', eo_get_blog_timezone() ),
'until' => new DateTime('2012-12-25 15:00', eo_get_blog_timezone() ),
'frequency' => 4,
'all_day' => 0,
'schedule' => 'daily',
);
$post_data = array(
'post_title'=>'The Event Title',
'post_content'=>'My event content',
);
$e = eo_insert_event($post_data,$event_data);
Tutorial
See this tutorial or this Gist on front-end event posting.
Parameters
array
|
$post_data = array() |
array of data to be used by wp_insert_post.
|
array
|
$event_data = array() |
array of event data
|
Return value
int
|
the post ID of the updated event
|
Hooks
Changelog
Resources