Problem: I would like to modify the terms associated with a parent post when a child post is added or modified using CRED.
Solution: Use the cred_save_data hook and wp_set_object_terms to manipulate the parent post.
add_action('cred_save_data_12345', 'set_parent_tutor_term_from_child',100,2); function set_parent_tutor_term_from_child($post_id, $form_data) { $taxonomy = 'tutor-status'; $tag = array( 'tutor-term-slug' ); $parent_id = get_post_meta($postid, '_wpcf_belongs_tutorslug_id', true); wp_set_object_terms( $parent_id, $tag, $taxonomy, true ); }
Change 12345 to match your CRED form ID, change tutor-status to match your Tutor Status taxonomy slug, change tutor-term-slug to match the term slug you want to associate with the parent post, and change tutorslug to match your tutor post type slug.
Relevant Documentation: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://codex.wordpress.org/Function_Reference/wp_set_object_terms
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 7 years, 2 months ago.
Assisted by: Christian Cox.