There is no current_time function?? That's weird, the functions work for the other form title I am auto populating, haha. Here is the other code, can you tell me why it is working if there is no "current time" function?
////////
// Display Current Date
add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return date( 'F j, Y', current_time( 'timestamp' ));
}
/////////////
// Auto Populate Repair Title
add_action('cred_submit_complete', 'auto_populate_title',10,2);
function auto_populate_title($post_id, $form_data){
// Edit form ID to match form ID
if ($form_data['id']==888) {
$parentpost_id = toolset_get_related_post($post_id, 'membership-vehicle-repair' );
$parent_title = get_the_title($parentpost_id);
$today_date = current_time( 'Y-m-d' );
$childpost_title = array(
'ID' => $post_id,
'post_title' => $parent_title . ' - ' . $today_date,
);
wp_update_post( $childpost_title );
}
}
The code you shared gave me this error: Parse error: syntax error, unexpected '$today_date' (T_VARIABLE) in /wp-content/themes/oceanwp-child/functions.php on line 113
It is also not changing or updating the title for the Payment Plan Application form.
I looked through my code again and spotted a typo, the last line should read
wp_update_post($payment_plan);
Sorry about that.
I then checked the code on my own site and it worked correctly.
As for current_time, it seems it's a WordPress function, although it seems somewhat redundant as it is doing the same as the native PHP date function, so either should work.