forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
32 lines
1.0 KiB
Twig
32 lines
1.0 KiB
Twig
/**
|
|
* Implements hook_user_cancel().
|
|
*/
|
|
function {{ machine_name }}_user_cancel($edit, UserInterface $account, $method) {
|
|
switch ($method) {
|
|
case 'user_cancel_block_unpublish':
|
|
// Unpublish nodes (current revisions).
|
|
module_load_include('inc', 'node', 'node.admin');
|
|
$nodes = \Drupal::entityQuery('node')
|
|
->accessCheck(FALSE)
|
|
->condition('uid', $account->id())
|
|
->execute();
|
|
node_mass_update($nodes, ['status' => 0], NULL, TRUE);
|
|
break;
|
|
|
|
case 'user_cancel_reassign':
|
|
// Anonymize nodes (current revisions).
|
|
module_load_include('inc', 'node', 'node.admin');
|
|
$nodes = \Drupal::entityQuery('node')
|
|
->accessCheck(FALSE)
|
|
->condition('uid', $account->id())
|
|
->execute();
|
|
node_mass_update($nodes, ['uid' => 0], NULL, TRUE);
|
|
// Anonymize old revisions.
|
|
\Drupal::database()->update('node_field_revision')
|
|
->fields(['uid' => 0])
|
|
->condition('uid', $account->id())
|
|
->execute();
|
|
break;
|
|
}
|
|
}
|