Created
January 17, 2012 20:30
-
-
Save billerickson/1628700 to your computer and use it in GitHub Desktop.
Gravity Forms - UNIX Timestamp
This file contains hidden or 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_post_submission_1', 'be_event_timestamp', 10, 2 ); | |
/** | |
* Create a UNIX timestamp based on Gform date fields | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/gravity-forms-unix-timestamp | |
* @link http://www.gravityhelp.com/documentation/page/Gform_post_submission | |
* | |
* 'gform_post_submission' applies to all forms, append form ID to specify | |
* | |
* @param array $entry | |
* @param array $form | |
* @return array | |
*/ | |
function be_event_timestamp( $entry, $form ) { | |
$start_date = get_post_meta( $entry['post_id'], 'be_event_start_date', true ); | |
if( $start_date ) { | |
$timestamp = strtotime( $start_date ); | |
update_post_meta( $entry['post_id'], 'be_event_start_date_unix', $timestamp ); | |
} | |
$end_date = get_post_meta( $entry['post_id'], 'be_event_end_date', true ); | |
if( $end_date ) { | |
$timestamp = strtotime( $end_date ); | |
update_post_meta( $entry['post_id'], 'be_event_end_date_unix', $timestamp ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment