Home›Types Community Support›[Resolved] delete_post not firing when deleting post from cred_delete_post_link
[Resolved] delete_post not firing when deleting post from cred_delete_post_link
The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
I am trying to execute custom code when a post is deleted. I've written a simple function using delete_post to delete a user when a user custom field matches the post ID of the post being deleted. When I delete the post from the front end using a link created from cred_delete_post_link, delete_post does not fire and the use is not deleted. If I delete the post from the back end delete_post does fire, the function works and the user is deleted.
Firstly, please note that you are posting in the Community Forum for users of the free Types plugin. As a Toolset customer you can and should post in the Technical Support forum which we prioritise and where you should receive speedier service.
Regarding the issue, I just tested it myself and it does trigger the delete_post and deleted_post hooks.
Looking at the CRED source code the deletion happens using the standard wp_delete_post function, so it would be odd if the hooks were not triggered.
When you insert the cred_delete_post_link you specify whether the post will be trashed or deleted. Does your shortcode have the action="delete" attribute?
If the post is trashed rather than deleted the hooks won't be triggered.