[wp-hackers] wp_delete_term inconsistence use of action hooks

Lox lox.dev at knc.nc
Sun Jun 19 23:55:15 UTC 2011


Hello,

I am working on a plugin that stores images and thumbnails for any term from
any configured taxonomy.

I make use of the wordpress metadata API to store informations about the
terms images and their thumbnails in a meta_termmeta table.

The problem comes when deleting a term. When a term get deleted, I need to
delete the its image and thumbnails.
The action hook I use is delete_term, action hook fired in wp_delete_meta
function.

Here is what I do in my delete_term function:

- I select the term's image/thumbnails informations using wp_get_metadata
function
- I then loop through the thumbnails informations and I delete those
- I finally delete the metadata using wp_delete_metadata function

My problem here is that when the delete_term action get fired, the term is
already deleted from the database, so the wp_get_metadata function don't
return the term metadata that I need before deleting it.

There is no pre_delete_term action, there is no delete_term / deleted_term
actions hook scheme, and definitely no action hook before the term is
deleted.

Any thought on how I can handle this?

-- 
Lox
lox.dev at knc.nc


More information about the wp-hackers mailing list