You are here

function comment_user_cancel in Drupal 7

Same name and namespace in other branches
  1. 8 core/modules/comment/comment.module \comment_user_cancel()
  2. 9 core/modules/comment/comment.module \comment_user_cancel()

Implements hook_user_cancel().

File

modules/comment/comment.module, line 1400
Enables users to comment on published content.

Code

function comment_user_cancel($edit, $account, $method) {
  switch ($method) {
    case 'user_cancel_block_unpublish':
      $comments = comment_load_multiple(array(), array(
        'uid' => $account->uid,
      ));
      foreach ($comments as $comment) {
        $comment->status = 0;
        comment_save($comment);
      }
      break;
    case 'user_cancel_reassign':
      $comments = comment_load_multiple(array(), array(
        'uid' => $account->uid,
      ));
      foreach ($comments as $comment) {
        $comment->uid = 0;
        comment_save($comment);
      }
      break;
  }
}