Skip to content

Instantly share code, notes, and snippets.

@mahbubme
Last active August 21, 2019 04:12
Show Gist options
  • Save mahbubme/7d5abaa560734a3e595ade55e8eb8b61 to your computer and use it in GitHub Desktop.
Save mahbubme/7d5abaa560734a3e595ade55e8eb8b61 to your computer and use it in GitHub Desktop.
Update _EventStartDateUTC & _EventEndDateUTC meta of tribe events.
<?php
// update utc time for tribe events
function wpuf_update_event_details( $post_id, $form_id, $form_settings, $form_vars ) {
if ( !empty( $post_id ) && !empty( $form_settings['post_type'] ) && $form_settings['post_type'] == 'tribe_events' ) {
$eventStartDate = isset( $_POST['_EventStartDate'] ) ? $_POST['_EventStartDate'] : '';
$eventEndDate = isset( $_POST['_EventEndDate'] ) ? $_POST['_EventEndDate'] : '';
if ( !empty( $eventStartDate ) || !empty( $eventEndDate ) ) {
update_post_meta( $post_id, '_EventStartDateUTC', $eventStartDate );
update_post_meta( $post_id, '_EventEndDateUTC', $eventEndDate );
}
}
}
add_action( 'wpuf_add_post_after_insert', 'wpuf_update_event_details', 10, 4 );
add_action( 'wpuf_edit_post_after_update', 'wpuf_update_event_details', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment