function node_user_cancel
Same name in other branches
- 7.x modules/node/node.module \node_user_cancel()
- 9 core/modules/node/node.module \node_user_cancel()
- 8.9.x core/modules/node/node.module \node_user_cancel()
Implements hook_user_cancel().
File
-
core/
modules/ node/ node.module, line 667
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;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.