Skip Navigation

[Resolved] capture generic date field

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 6 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1101391

Hi
I have this in my form a generic field of type DATE:
[cred_generic_field field='expirydate' type='date' class='' urlparam='']
{
"required":1,
"validate_format":0,
"default":""
}
[/cred_generic_field]

in my php:
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
//change booking expiry date
if ( 25306 == $form_data['id'] ) {
$expirydate = $_POST['expirydate'];
update_post_meta( $post_id, '_cred_post_expiration_time', $expirydate );
}

It does not work, I tried even to display the content of $expirydate, it shows empty.
I checked my code with other types of variable than date, it works, but not with date.
Thank you for helping.

#1101413

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Try sending the $_POST object to your debug logs like this, so that you can see the format:

error_log(print_r($_POST, true));

I don't remember the format off the top of my head, but I think you will find the value of the expirydate field submitted with the form is inside an array or object.

If you get stuck, let me know.