Created
May 13, 2013 08:16
-
-
Save ccamara/5566877 to your computer and use it in GitHub Desktop.
Prevents nodes and/or comments to be deleted. #drupal #nodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//stop deletion of nodes and comments | |
function MODULE_form_alter (&$form, &$form_state) { | |
//stop any node/comment deletions | |
if ((isset($form['operation']['#value']) && $form['operation']['#value'] == 'delete') || $form['#id'] == 'node-delete-confirm' || $form['#id'] == 'comment-confirm-delete') { | |
//set a message... | |
drupal_set_message('your message'); | |
//stop people from being able to submit the delete form (and in turn stop the delete) | |
unset($form['actions']['submit']); | |
//set the "cancel" link text to something else | |
$form['actions']['cancel']['#title'] = t('Back to previous page'); | |
} | |
//Stop the deletion of user accounts | |
if ($form['#id'] == 'user-multiple-cancel-confirm' || $form['#id'] == 'user-cancel-confirm-form') { | |
drupal_set_message(t('You are attempting to delete a user account. Users on this site cannnot be deleted, to disable this users account, please block the account. Users with blocked accounts will not be able to login.'), 'error'); | |
unset($form['user_cancel_method']); | |
unset($form['user_cancel_confirm']); | |
unset($form['user_cancel_notify']); | |
unset($form['actions']['submit']); | |
$form['actions']['cancel']['#title'] = t('Back to previous page'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet has been taken from here: http://drupal.org/node/506222 and authored by sebanthony