Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
Last active June 30, 2022 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woodwardtw/60ba3f4f325e6fe786a4fa09c141015a to your computer and use it in GitHub Desktop.
Save woodwardtw/60ba3f4f325e6fe786a4fa09c141015a to your computer and use it in GitHub Desktop.
makes a live event that does require manual update
<?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