Toolset Auto Populate Title with User’s Name & Date

////////
// Display Current Date
add_shortcode('wpv-post-today', 'today_shortcode');
    function today_shortcode() {
    return date( 'F j, Y', current_time( 'timestamp' ));
}

/////////////
// Auto Populate 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) {
        // edit membership-vehicle-repair to match your form name
        $parentpost_id = toolset_get_related_post($post_id, 'membership-vehicle-repair' );
        $parent_title = get_the_title($parentpost_id);
        $today_date = date('Y-m-d');
        $childpost_title = array(
            'ID'           => $post_id,
            'post_title'   => $parent_title . ' - ' . $today_date,
        );
   wp_update_post( $childpost_title );
	}
}

Leave a Reply