Last active
December 7, 2017 02:04
-
-
Save kenmasters/262dc4da523238d85be64f8698d21347 to your computer and use it in GitHub Desktop.
GFORM merge tag change date display format wen using {all_fields}.
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
// Code placement: current theme functions.php | |
// Change date displayed format. | |
// Example adding a date field in a dropdown/datefield format is dd-mm-yy and value `09-09-2017`, | |
// By adding this filter it will display as `09-September-2017`. | |
// Take note that in gforms docs: https://www.gravityhelp.com/documentation/article/gform_merge_tag_filter/#5-date-field | |
// priority is `10` and is working only for datepicker but not for dropdown and datefield, | |
// here is changed to `15` to ensure filter would not be overriden. | |
add_filter( 'gform_merge_tag_filter', 'date_display_custom', 15, 5 ); | |
function date_display_custom ( $value, $merge_tag, $options, $field, $raw_value ) { | |
if ( $field->type == 'date') { | |
return date_i18n( 'd-F-Y ', strtotime( $raw_value ) ); | |
} | |
return $value; | |
} | |
REFERENCE: https://www.gravityhelp.com/documentation/article/gform_merge_tag_filter/#5-date-field |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment