W3cubDocs

/Drupal 8

function node_user_predelete

node_user_predelete($account)

Implements hook_ENTITY_TYPE_predelete() for user entities.

File

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

Code

function node_user_predelete($account) {
  // Delete nodes (current revisions).
  // @todo Introduce node_mass_delete() or make node_mass_update() more flexible.
  $nids = \Drupal::entityQuery('node')
    ->condition('uid', $account->id())
    ->execute();
  entity_delete_multiple('node', $nids);
  // Delete old revisions.
  $storage_controller = \Drupal::entityManager()->getStorage('node');
  $revisions = $storage_controller->userRevisionIds($account);
  foreach ($revisions as $revision) {
    node_revision_delete($revision);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!node!node.module/function/node_user_predelete/8.1.x