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
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?
from the frontend, please.
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?
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
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 );