Last active
August 21, 2019 04:12
-
-
Save mahbubme/7d5abaa560734a3e595ade55e8eb8b61 to your computer and use it in GitHub Desktop.
Update _EventStartDateUTC & _EventEndDateUTC meta of tribe events.
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 | |
// 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