SHOW:
|
|
- or go back to the newest paste.
1 | //http://www.stephenharris.info/2012/front-end-event-posting/ | |
2 | //http://www.gravityhelp.com/documentation/page/Gform_after_submission | |
3 | ||
4 | add_action("gform_after_submission_8", "add_new_event", 10, 2); | |
5 | function add_new_event($entry, $form){ | |
6 | ||
7 | //getting post | |
8 | $post = get_post($entry["post_id"]); | |
9 | ||
10 | //Set the post data - event data | |
11 | ||
12 | $post_data =array( | |
13 | 'post_title'=>$entry['1'], | |
14 | 'post_content'=>$entry['2'], | |
15 | 'tax_input'=>array( | |
16 | 'event-venue'=>array($entry['5']), | |
17 | 'event-category'=>$entry['4'], | |
18 | ) | |
19 | ); | |
20 | ||
21 | $start = new DateTime($entry['6'],eo_get_blog_timezone()); | |
22 | $end = new DateTime($entry['18'],eo_get_blog_timezone()); | |
23 | $event_data =array( | |
24 | 'schedule' =>'once', //specifies the reoccurrence pattern | |
25 | 'all_day' => 1, //1 if its an all day event, 0 if not | |
26 | 'start' => $start, //start date (of first occurrence) as a datetime object | |
27 | 'end' => $end, //end date (of first occurrence) as a datetime object | |
28 | ); | |
29 | ||
30 | //Finally, Insert event. | |
31 | $post_id = eo_insert_event($post_data,$event_data); | |
32 | ||
33 | } | |
34 | //stop gravity from adding a second event | |
35 | add_filter("gform_disable_post_creation_8", "disable_post_creation", 10, 3); | |
36 | function disable_post_creation($is_disabled, $form, $entry){ | |
37 | return true; | |
38 | } |