Problem:
I have custom field “wpcf-start-date” and “wpcf-end-date”.
I'm trying to get the end date to be the same as the start date if the user submits the form leaving the end date blank.
Solution:
Please add this code in your theme’s or child theme’s functions.php file:
function save_data_form_48($post_id, $form_data){ // Change your CRED Form "ID" accordingly below if ($form_data['id']==48){ if(isset($_POST['wpcf-end-date']['display-only']) && $_POST['wpcf-end-date']['display-only'] == ''){ // End date is empty $custom_date = get_post_meta( $post_id, 'wpcf-start-date', true ); update_post_meta($post_id, 'wpcf-end-date', $custom_date); } } } add_action('cred_save_data', 'save_data_form_48',10,2);
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
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 |
---|---|---|---|---|---|---|
- | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | - |
- | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
This topic contains 4 replies, has 2 voices.
Last updated by 7 years, 3 months ago.
Assisted by: Noman.