Sure - here you go. Maybe I got something wrong piecing it together with the forms array and the content you modified from the original version.
add_action('cred_save_data', 'toolset_fix_layout_relationship_bug',10,2);
function toolset_fix_layout_relationship_bug($post_id, $form_data) {
// one array for each form
$hash = array(
array(
'id' => 198,
'slug' => 'household-household-term',
),
array(
'id' => 507,
'slug' => 'product-listing_ad',
),
array(
'id' => 532,
'slug' => 'ad_ad-resposne',
),
array(
'id' => 534,
'slug' => 'ad_ad-resposne',
),
array(
'id' => 735,
'slug' => 'group_conversation',
),
array(
'id' => 735,
'slug' => 'member-profile_conversation',
),
array(
'id' => 762,
'slug' => 'group_group-member',
),
array(
'id' => 760,
'slug' => 'group_group-member',
),
array(
'id' => 228,
'slug' => 'household_household-child',
),
array(
'id' => 207,
'slug' => 'household-term-household-course',
),
array(
'id' => 399,
'slug' => 'product-listing_household-material',
),
array(
'id' => 399,
'slug' => 'household-course_household-material',
),
array(
'id' => 381,
'slug' => 'household-child_household-enrollment',
),
array(
'id' => 381,
'slug' => 'household-course_household-enrollment',
),
array(
'id' => 447,
'slug' => 'household-child_household-transcript',
),
array(
'id' => 328,
'slug' => 'product-listing_product-review-ext',
),
array(
'id' => 340,
'slug' => 'product-listing_product-review',
),
array(
'id' => 340,
'slug' => 'household-child_product-review',
),
);
// closure to find the matching array hash item and slug
$find = function( $var ) use ($form_data)
{
$el = ($var['id']==$form_data['id']);
return $el;
};
// create an array of form IDs where you want to apply this code
$forms = array_column( $hash, 'id' );
if ( in_array( $form_data['id'], $forms ) )
{
// find the slug array in the matching hash item and use it to connect the parent post
$thisHash = array_filter( $hash, $find );
$slugs = $thisHash[array_keys($thisHash)[0]]['slugs'];
foreach( $slugs as $slug ) {
$parent_id = $_POST['@' . $slug . '_parent'];
$parent = toolset_connect_posts( $slug, $parent_id, $post_id );
}
}
}