Navigation überspringen

[Gelöst] Delete related posts in a 1to1 or 1toMany Relationship, when deleting on post

This support ticket is created vor 4 Jahren, 11 Monaten. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 4 Jahren, 11 Monaten.

Assistiert von: Minesh.

Author
Artikel
#1479359

I have a contact database with post type 'contact' - I am attaching the post type 'actor profile' to it with a one-to-one relationship.

I now would like to delete either the 'contact' or the 'actor profile'.

When I delete one of the two, the other post should be deleted too.

How can I achieve this?

Thanks for your help!
Tobi

#1480661

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to know from where you are going to delete the post from your post type - from backend or frontend?

#1480743

from the frontend, please.

#1480765

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Sorry but from where exactly on the frontend. Can you please share the problem URL where you want to display the delete post link?

#1481019

If I delete this post:
versteckter Link

Also the connected contact should be deleted

And vice versa: if this contact is deleted:
versteckter Link
then the related actor profile should also be deleted.

Thanks!
Tobi

#1482563

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

There is no such native feature to delete the related posts when one post deleted which in a relationship.

However - you should try to use the native WordPress hook: post_updated

Please check the related example: https://toolset.com/forums/topic/before_delete_post-hook-not-working/#post-566759

You should try to use the post-relationship API function: toolset_disconnect_posts

For example:

$parent = 999;
$child = 222;
toolset_disconnect_posts( 'relationship-slug', $parent, $child );