You are here

function node_user_cancel in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_user_cancel()
  2. 7 modules/node/node.module \node_user_cancel()
  3. 9 core/modules/node/node.module \node_user_cancel()

Implements hook_user_cancel().

File

core/modules/node/node.module, line 635
The core module that allows content to be submitted to the site.

Code

function node_user_cancel($edit, UserInterface $account, $method) {
  switch ($method) {
    case 'user_cancel_block_unpublish':

      // Unpublish nodes (current revisions).
      $nids = \Drupal::entityQuery('node')
        ->accessCheck(FALSE)
        ->condition('uid', $account
        ->id())
        ->execute();
      \Drupal::moduleHandler()
        ->loadInclude('node', 'inc', 'node.admin');
      node_mass_update($nids, [
        'status' => 0,
      ], NULL, TRUE);
      break;
    case 'user_cancel_reassign':

      // Anonymize all of the nodes for this old account.
      \Drupal::moduleHandler()
        ->loadInclude('node', 'inc', 'node.admin');
      $vids = \Drupal::entityTypeManager()
        ->getStorage('node')
        ->userRevisionIds($account);
      node_mass_update($vids, [
        'uid' => 0,
        'revision_uid' => 0,
      ], NULL, TRUE, TRUE);
      break;
  }
}