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.
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
My issue is resolved now. Thank you!