Skip Navigation

[Resolved] action hook fired before post will be deleted ?

This support ticket is created 2 years, 9 months ago. 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.

This topic contains 3 replies, has 2 voices.

Last updated by Christopher Amirian 2 years, 9 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2304199

Tell us what you are trying to do?
Add a button / link to a list of posts that allows to delete the referring post , which I already accomplished, but ...

If that button / link will be hit, I need to hook into the process and catch post_id and a specific post meta before that post will be deleted in order to delete further posts and the matching user to which those posts refer (we are talking about patient files here) as well as referring file upload paths of the 'wordpress file download' plugin by JoomUnited.

Is there any documentation that you are following?
Checked the list of toolset hooks but didn't find a match - to my understanding of those hooks - at first glance. English isn't my primary language so I might have ignored accidentally.

What is the link to your site?
hidden link

Are there any Toolset or native WordPress pre-deletion hooks that include the ID of the post to be deleted?

Regards,

Sven

#2304365

Christopher Amirian
Supporter

Languages: English (English )

Hi Sven,

Toolset has a hook to redirect the page to a new URL while deleting a post:

https://toolset.com/documentation/programmer-reference/cred-api/#cred_redirect_after_delete_action

The purpose of cred_redirect_after_delete_action is to redirect the page after delete, but the good point is that you will have access to the post ID that is being deleted. So there you can access the meta information of the post and do whatever is needed.

Also, the "cred_before_save_data" hook is another one and it will trigger before any data is processed, so you can make use of that if needed.

https://toolset.com/documentation/programmer-reference/cred-api

As this is a customization you might need a developer to help you out, if that is the case, then we suggest that you take a look here for hiring one:

https://toolset.com/contractors

Thank you.

#2304537

Hi Christopher,

thanks for the input. Just to be clear: cred_before_save_data also fires on deletions, not only on creations?

Regards,

Sven

#2304893

Christopher Amirian
Supporter

Languages: English (English )

Hi Sven,

I did not check that personally but from the look of the description, it should be. I suggest that you test that by forcing the PHP to die() and see if it triggers on delete:

hidden link

If it triggers, then the website will break. Then you will know that it triggers on Delete or not.

If not, you can use the other one that I mentioned which definitely triggers before dthe elete action.

Thank you.