I have a CRED form that is being used to update our 'maintenance issues' custom posts.
We would like to capture a date & time of when a user sets the custom field 'issue status' to complete.
What I've done so far is:
- create a custom date field called 'date completed'
- set a Conditional display rule that only shows if Issue Status = Completed ... screen shot attached
- on my CRED form I've added the 'completed date' field ... screen shot attached
Thank you for contacting Toolset Support. The steps you have done looks correct. Can you please make sure to Register the "wpv-post-today'’ shortcode first in Toolset >> Settings >> Front-end Content >> Third-party shortcode arguments (see attached screenshot: Register custom shortcode.png)
Thanks for your message. I've now registered the shortcode as per screenshot attached.
If I just put the shortcode on it's own it seems to work. Here is a test:
1. Screenshot shows the code in the CRED with the field and the shortcode on it's own
2. Screenshot shows the output ... you can see the field is empty by the shortcode and outputted the date & time ok
That's working now and I've managed to get it to work how we need it so that's great thank you.
But, when we export the data I notice that the format of the custom date fields are incorrect ... maybe in the time stamp format. Ideally we need it exporting in the date format like the default date modified field is in the attached screenshot.
In the screenshot you can see the custom date field 'Issue Date' coming out as '1487852248' instead of '2017-07-08'
Oh dear ... that's quite a limitation for what we need.
If there is no way of fixing this, through php or js, is a possible workaround to use a single line text field and have the time stamp capture here in stead?
Final check ... I would like to use both the date field and the text field so need both codes in the functions.php file.
I've tried the single shortcode for both but the one working for date doesn't seem to work for the text field. So I also tried both like this:
// used to populate text field
add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return date("d M Y h:m:s", time());
}
// used to populate date field
add_shortcode('wpv-today-day', 'today_shortcode');
function today_shortcode($atts) {
return current_time( 'timestamp', 0 );
}
But it crashes the site. Would you expect it to crash the site if I put both in?
Yes, I am expecting same. Because we can’t use two functions with same name. Now I have updated function name and it will not generate any issue.
// used to populate text field
add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return date("d M Y h:m:s", time());
}
// used to populate date field
add_shortcode('wpv-today-day', 'today_day_shortcode');
function today_day_shortcode($atts) {
return current_time( 'timestamp', 0 );
}