This thread is resolved. Here is a description of the problem and solution.
Problem:
I am using Conductor plugin to display data on a page. I have a types Date Field but its format is wrong (y-m-d format), how to convert date it as m-d-y format?
Solution:
- Add the follow custom JS code to change the date format, modify as needed:
jQuery(document).ready(function( $ ){
// y-m-d to m-d-y
jQuery(document).find('.custom-field-wpcf-date-of-baptism').each(function(index, element) {
var old_format = jQuery(this).find('.custom-field-val').text();
var old_format_array = old_format.split('-');
var new_format = old_format_array[1] +'-'+old_format_array[2] +'-'+old_format_array[0];
jQuery(this).find('.custom-field-val').text(new_format);
});
});
==> Whereas ‘.custom-field-wpcf-date-of-baptism’ should be replaced with your custom field slug.
Hi,
I have created a custom post type (church user) and the related post fields (see attached pic)
CPT-fields.jpg. To enter the data I am using Formidable Forms Pro (see attached pic) map-frmfields. And the mapping works fine. The problem is with the date and the file upload (picture).
See attached Grid-CPT-output.
FF Pro saves the date in y-m-d format, and that is what is saved in the wpcf-date-of-baptism field and displayed. I am using the Conductor plugin to display data and it just outputs what it finds in the wpcf-fields that are mapped. I would like to have the date saved in the
wpcf-date-of-baptism field in m-d-y format!.
I am not a programmer so not sure how to approach this...
Thank you for the fast response...
I am not sure what you mean using the shortcode? Where would this line go? Why is the style= text for a date field?
[types field='event-date' style='text' format='m-d-Y'][/types]
Would I add this to the code snippets that I have?
I am using the Formidable Forms Pro to enter data not types? as described above. After Formidable Forms passes the date to
the wpcf-date-field I want the stored date for be in m-d-Y format.
First we need to get clear on your setup, as I understand you are doing something like this:
- Date Field is added using Types, into the Grid-CPT.
- That date field’s value is being updated using the Formidable form.
- Then the date field and content is shown on the page using Conductor plugin, using some shortcode.
Is all the above correct or there is something missing?
There is something wrong with the mapping of the date field as it is not getting correct value from the Types field. So you need to consult with the person who has done mapping for you, since the problem is in mapping and not the date field itself.
Alternatively, I would suggest to use Toolset Views plugin to display data on the page, instead of Conductor plugin. Then you will be able to display all fields correctly and will have control on correct date format. You will use the previously given shortcode in the View. Toolset Views also allows you to easily display posts, content, custom fields in list, grid and tables style as well. https://toolset.com/home/views-create-elegant-displays-for-your-content/ https://toolset.com/documentation/user-guides/#views-topics
1. Using Types I created a CPT and custom fields ( see fig CPT-fields.hjpg attached)
2. I created a form that maps the form fields to the wpcf-xxx fields in Types... And that works
fine!! (See map-frmfields.jpg)
3. I use Conductor plugin to display the data stored in wpcf-xxxxxx (types fields) and that works
fine too!!!
These 3 pieces are working fine.... I am NOT a programmer!
Problem: The forms program (Formidable Forms Pro) saves the date in Y-m-d format. I want Types to save the date (wpcf-date-of-baptism) in m-d-Y format! In the attached pic u can see the output is still in Y-m-d format......... 🙁
There must be a way to have a code snippet force types to save the date in specified format.
Views would work but it takes alot of code to get the output to look good when the Conductor plugin will use post, CPT, woo commerce, etc. and allow me to output data in grids, lists, etc very easy in minutes... Conductor works very good and soon will allow me to modify the output and
my problem will go away. Until then.....
I need to look into your setup, please provide temporary access (WP-Admin and FTP Login info) to your site (possibly staging site). Your next answer will be private which means only you and I have access to it.
=== Please backup your database and website ===
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.
✙ Please add the Links to the [Form] Edit Screen, [Page] Edit Screen where you have inserted the form, CPT link or name, and also link to the page where you have created the date field.
1. I can see that you are using Cloudflare CDN. Please clear / purge / delete Cloudflare cache completely. Clear out your website cache, plugins cache, server cache (if any), browser cache too. Also please temporarily disable CDN from Cloudflare control panel or set it as development mode, so it shows our changes on site.
2. I have tried to create a new conductor on your site, but I can not save the fields in the new conductor. I have also tried to test your conductor “test grid” but it does not effects on the page, even I have deleted the shortcode form the page but still it displaying the list on the front page.
I have recorded a small video for you: hidden link
Thanks for this, cache issue solved and site is working good now. I am working now and trying to do this with custom JS, I will update you with results soon.
I have installed and activated the Simple Custom CSS and JS plugin and added the custom JS code to change the date format and now it is displaying the date in expected format m-d-y. Please check here: hidden link
jQuery(document).ready(function( $ ){
// y-m-d to m-d-y
jQuery(document).find('.custom-field-wpcf-date-of-baptism').each(function(index, element) {
var old_format = jQuery(this).find('.custom-field-val').text();
var old_format_array = old_format.split('-');
var new_format = old_format_array[1] +'-'+old_format_array[2] +'-'+old_format_array[0];
jQuery(this).find('.custom-field-val').text(new_format);
});
});
Thank you for the support and solving the problem with a JS snippet.... That is the kind of solution I wanted. The Formidable Forms support suggested something similar but was not a generic solution like yours. Toolset support is super good and slowly I am learning to use it more.
That is why I am a lifetime owner of Toolset.
The date is now in the correct format.... and this will work for any plugin that I use with Types.
I will move my other CSS to the plugin that you installed because JS might be useful in other issues.
Now my last issue is the picture field but I will research that more and submit a ticket for that soon.
Thank You
Mel
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.