add_action('cred_save_data', 'func_add_parent_terms_automatically',10,2);
function func_add_parent_terms_automatically($post_id, $form_data){
// if a specific form
if ($form_data['id']==9999){
$terms = wp_get_object_terms( $post_id, 'taxonomy-slug' );
foreach($terms as $term){
while($term->parent != 0 && !has_term( $term->parent, 'taxonomy-slug', $post_id)){
// move upward until we get to 0 level terms
wp_set_post_terms($post_id, array($term->parent), 'taxonomy-slug', true);
$term = get_term($term->parent, 'taxonomy-slug');
}
}
}
}
Where:
- Replace 9999 with your original form ID
- Replace taxonomy-slug with your original taxonomy slug
I just show you the way - you need to adjust the code accordingly where needed.
If you do not able to do so, I need a problem URL and access details and I will try to adjust the code accordingly.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.