Hi Waqar, thank you for the suggestion. I setup the "delete_post" hook, now it works, I get the output in debug.log.
My problem now is that I need to get the parent post ID and the value of a custom field of the deleted Repeatable Group post.
I tried this:
$team = toolset_get_related_post( $post_id, 'fishes' );
$fishmeasure = get_post_meta( $post_id, 'wpcf-fishmeasure', true );
But I get in debug.log zero and empty value:
$team: 0
$fishmeasure:
How can I get those values?
cheers
Hello,
Please check the WP document:
https://developer.wordpress.org/reference/hooks/delete_post/
Take note, by the time the hook triggers, the post comments and metadata would have already been deleted. Use the before_delete_post hook to catch post deletion before that.
This action hook triggers after relationships are deleted too.
So in your case, please try the action hook "before_delete_post":
https://developer.wordpress.org/reference/hooks/before_delete_post/
Hi Luo, thanks for the support. I replaced delete_post with before_delete_post.
Now I can get the $fishmeasure:
$fishmeasure = get_post_meta( $post_id, 'wpcf-fishmeasure', true );
But I still get zero when I try to get the Parent ID with:
$team = toolset_get_related_post( $post_id, 'fishes' );
Any suggestion?
thanks
I have tried it in my localhost with a fresh WP installation, it works fine, I can get the parent post ID within before_delete_post action hook.
Please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/
2) In case it is a compatibility problem, please deactivate all other plugins, and switch to WordPress default theme 2021, deactivate all other custom PHP/JS code snippets, and test again
3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/