-
-
Save kaskad88/eb35ae49f312d95746b13d3fde25d0f1 to your computer and use it in GitHub Desktop.
add_filter( 'do_shortcode_tag', function ( $output, $tag, $attr ) { | |
if ( 'jet_engine' !== $tag ) { | |
return $output; | |
} | |
if ( empty( $attr['component'] ) || 'meta_field' !== $attr['component'] ) { | |
return $output; | |
} | |
$date_keys = array( 'feastday', 'date_field_1', 'date_field_2' ); // date fields list | |
if ( empty( $attr['field'] ) || ! in_array( $attr['field'], $date_keys ) ) { | |
return $output; | |
} | |
if ( empty( $output ) ) { | |
return $output; | |
} | |
$format = get_option( 'date_format' ); // or set custom date format. Ex.: $format = 'F j, Y'; | |
$output = date_i18n( $format, $output ); | |
return $output; | |
}, 10, 3 ); |
@codeintopixel According to the code, you did everything correctly
@kaskad88 Currently "Save as timestamp" option is ON for both fields, earlier when option was OFF it was showing correctly in mails.
I have tried and tested after adding this code, still showing in same format. This form is created using JetFormBuilder.
@codeintopixel Could you please attach a screen with your email template in JetFormBuilder https://tppr.me/4eT8f
Here you go @kaskad88
@codeintopixel for your case the code is above not needed.
Replace the string %customer-due-date%
on %customer-due-date|format_date%
in the content field.
This worked, one typo here though instead of hypen(-) we have to use underscore(_). As this is what macros accepting in form builder. Thank you for your quick responses. 👯
Can you share what exactly I have to replace in this code? I have 2 meta-fields(customer-due-date, due-date) which needs to be formatted in mail.
`add_filter( 'do_shortcode_tag', function ( $output, $tag, $attr ) {
if ( 'jet_engine' !== $tag ) {
return $output;
}
if ( empty( $attr['component'] ) || 'meta_field' !== $attr['component'] ) {
return $output;
}
$date_keys = array( 'customer-due-date', 'due-date' ); // date fields list
if ( empty( $attr['field'] ) || ! in_array( $attr['field'], $date_keys ) ) {
return $output;
}
if ( empty( $output ) ) {
return $output;
}
$format = get_option( 'date_format' ); // or set custom date format. Ex.: $format = 'F j, Y';
$output = date_i18n( $format, $output );
return $output;
}, 10, 3 );`