WORDPRESS - Oxygen - toolset

Auto-populate child content with parent content's title

Author: Aleš Sýkora, 11. 7. 2019

Snippet from our fan, who do not give us his name, just call him Another Unknown Toolset Fan.

This code also allows you to add the current date. If you do not want/need to display the date in the title, simply remove the shortcode, as well as well as the relevant code from the 'post-title' line.

// Display Current Date
add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return date( 'F j, Y', current_time( 'timestamp' ));
}
// Auto Populate Repair
add_action('cred_submit_complete', 'auto_populate_title',10,2);
function auto_populate_title($post_id, $form_data){
// Edit form ID to match your form's 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 );
}
}