Skip Navigation

[Resolved] Post date in form shows wrong date

This support ticket is created 5 years, 2 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by nabils 5 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1375273

Hi,
I am trying to use the form submission date as the post title.
[cred_field field='post_title' post='rental' value='[wpv-post-date format="F j, Y g:i a"]' urlparam='']

However, the date stored is not the same date of form submission.

#1375309

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand, you want to use the current date/time as your post title. If this is correct - you can use the Toolset Form's hook: cred_save_data.

For example - add the following code to your current theme's functions.php file
OR
To "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

 add_action('cred_save_data', 'func_build_post_title', 10, 2);
function func_build_post_title($post_id, $form_data) {

 if ($form_data['id']==9999) {
 
$post_title = date("F j, Y g:i a");
$slug = sanitize_title($post_title);
wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));
}
}

Where:
Replace 9999 with your CRED form ID.

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#1375339

My issue is resolved now. Thank you!