unpublish node when edit it
Hope this will help you, In my case i did it by updating the node and node_revision table's status column set to "0".following code is for form submit action you can do it for your delete action..

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
 if ($form_id == 'your form')   {
 $form['#submit'][] = 'mymodule_form_submit';
 }

}

function mymodule_form_submit($form, &amp;$form_state){
if (//your condition)
            {
            $query = db_update('node')
            -&gt;fields(array(
            'status' =&gt; 0,//unpublished the node
                ))
            -&gt;condition('nid',$form['nid']['#value'], '=')
            -&gt;execute();

            $query = db_update('node_revision')
            -&gt;fields(array(
            'status' =&gt; 0,//unpublished the node
                ))
            -&gt;condition('nid',$form['nid']['#value'], '=')
            -&gt;execute();
            }
        //  drupal_flush_all_caches(); 

}