unpublish node when edit it I have a content type calles survey, When admin deletes a survey, the survey results should still be accessible and not deleted as well. So I want to unpublish the node when click on the delete button(it will be better to change this delete button to unpublish button). but I dont know how to unpublished a node.
Any solution / alternative / suggestion will be greatly appreciated.
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(); 

}