Created
January 20, 2017 17:26
-
-
Save kjohnson/6804787420b0edc110af6e34da064904 to your computer and use it in GitHub Desktop.
Converts a formatted Ninja Forms date to a timestamp for compatibility with Custom Fields (Date Type)
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 | |
| // Requires PHP v5.3 or higher. | |
| add_filter( 'ninja_forms_create_post_meta_value', function( $meta_value, $post_type, $meta_key ){ | |
| // TODO: Update $post_type check. | |
| // TODO: Update $meta_key check. | |
| if( 'test' == $post_type && 'wpcf-test-date' == $meta_key ){ | |
| // Convert formatted date to timestamp for WP-Types compatibility. | |
| $meta_value = DateTime::createFromFormat( 'd/m/Y', $meta_value )->getTimestamp(); | |
| } | |
| return $meta_value; | |
| }, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment