Hy guys,
I have a code snippet that I use to autocomplete a post title from a cred form. It works however I have one problem. Here is the code I use.
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
add_action('cred_save_data', 'func_auto_post_name',10,2);
function func_auto_post_name($post_id, $form_data) {
if ($form_data['id']==798) {
$surname = get_post_meta($post_id, 'wpcf-student_surname', true);
$first_name = get_post_meta($post_id, 'wpcf-student-first-name', true);
$date_of_birth = get_post_meta($post_id, 'wpcf-date-of-birth-participant1', true);
$cptitle= $surname. ' - ' . $first_name. ' - ' . $date_of_birth;
$args = array('ID' => $post_id, 'post_title' => $cptitle);
wp_update_post($args);
}
}
My problem is with the date of birth. I do use a date field for this form. Once the form is updated it displays the entry. with the auto-created post title. The issue is that instead of the date being part of the post title it is just some numerical value. Any idea how i can
fix this issue.