Last active
June 30, 2022 19:22
-
-
Save woodwardtw/60ba3f4f325e6fe786a4fa09c141015a to your computer and use it in GitHub Desktop.
makes a live event that does require manual update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'gform_after_submission_3', function ( $entry ) { | |
if ( ! function_exists( 'tribe_create_event' ) ) { | |
return; | |
} | |
$start_date = rgar( $entry, '2' ); | |
$start_time = rgar( $entry, '3' ); | |
$end_date = rgar( $entry, '4' ); | |
$end_time = rgar( $entry, '5' ); | |
$args = array( | |
'post_type' => 'tribe_events', | |
'post_title' => rgar( $entry, '1' ), | |
'post_content' => rgar( $entry, '6' ), | |
'post_status' => 'publish', | |
'EventAllDay' => false, | |
'EventHideFromUpcoming' => false, | |
'EventShowInCalendar' => true, | |
'feature_event' => false, | |
'EventStartDate' => $start_date, | |
//'EventStartTime' => $start_time ? Tribe__Date_Utils::reformat( $start_time, 'H:i:s' ) : null, | |
'EventEndDate' => $end_date, | |
//'EventEndTime' => $end_time ? Tribe__Date_Utils::reformat( $end_time, 'H:i:s' ) : null, | |
); | |
GFCommon::log_debug( 'gform_after_submission: tribe_create_event args => ' . print_r( $args, 1 ) ); | |
$event_id = tribe_create_event( $args ); | |
GFCommon::log_debug( 'gform_after_submission: tribe_create_event result => ' . var_export( $event_id, 1 ) ); | |
} ); | |
//modified from https://docs.gravityforms.com/gform_after_submission/#h-8-create-an-events-calendar-plugin-event | |
//more details at https://gist.github.com/leepettijohn/0ab7e5a7474f9f77df20 - I didn't bother with the hours minute stuff bc I didn't care enough |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment