Skip Navigation

[Resolved] Updating a Parent field when an Intermediary Post is deleted

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.

This topic contains 1 voice and has 0 replies.

>
Author
Posts
#2811600

RESOLVED but leaving here to help others.

I have an intermediary CPT.

Before the intermediary CPT is deleted I want to update a custom field in the Parent of the intermediary CPT.

To do this:

add_action( 'toolset_before_association_delete', 'update_field2', 10, 5 );

function update_field2( $relationship_slug, $parent_id, $child_id, $intermediary_id, $association_uid ) {

if ( $relationship_slug == 'relationship-slug' ) {
update_post_meta ($parent_id, 'wpcf-field-to-update', 'value-to-update-it-with');
}
}