Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://www.stephenharris.info/2012/front-end-event-posting/
- //http://www.gravityhelp.com/documentation/page/Gform_after_submission
- add_action("gform_after_submission_8", "add_new_event", 10, 2);
- function add_new_event($entry, $form){
- //getting post
- $post = get_post($entry["post_id"]);
- //Set the post data - event data
- $post_data =array(
- 'post_title'=>$entry['1'],
- 'post_content'=>$entry['2'],
- 'tax_input'=>array(
- 'event-venue'=>array($entry['5']),
- 'event-category'=>$entry['4'],
- )
- );
- $start = new DateTime($entry['6'],eo_get_blog_timezone());
- $end = new DateTime($entry['18'],eo_get_blog_timezone());
- $event_data =array(
- 'schedule' =>'once', //specifies the reoccurrence pattern
- 'all_day' => 1, //1 if its an all day event, 0 if not
- 'start' => $start, //start date (of first occurrence) as a datetime object
- 'end' => $end, //end date (of first occurrence) as a datetime object
- );
- //Finally, Insert event.
- $post_id = eo_insert_event($post_data,$event_data);
- }
- //stop gravity from adding a second event
- add_filter("gform_disable_post_creation_8", "disable_post_creation", 10, 3);
- function disable_post_creation($is_disabled, $form, $entry){
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement