delete_attachment isn't fired
-
Hi,
I’m developing a custom gallery which uses an XML DB for the purpose.
Now I would like to synchronize the XML with the Media Library: when deleting an image from the Media Library, the ID of the image stored in the XML file will be deleted too, so:function onWpDelete( $targetID ){ $filePath = '../wp-content/plugins/the-plugin/gallery.xml'; if( file_exists( $filePath ) ){ $doc = new DOMDocument(); $doc->load($filename); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $ids = $doc->getElementsByTagName('ID'); foreach( $ids as $id ){ if( $id->nodeValue == $targetID ){ try{ $id->parentNode->removeChild($id); } catch(Exception $e){ wp_die('DOMDocument: ' . $e->getmessage() ); }//try - catch break; }//if }//foreach }//if }//onWpDelete add_action('delete_attachment', 'onWpDelete');but I can’t get the delete_attachment hook fired when I delete an image from the Media Library and can’t make it working.
I even tried:add_action('delete_attachment', 'onWpDelete', 1', 1);because of the $postid parameter for the hook but it doesn’t work.
What’s the correct way to do that?
Thank you
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘delete_attachment isn't fired’ is closed to new replies.