function node_user_cancel

Same name in other branches
  1. 9 core/modules/node/node.module \node_user_cancel()
  2. 8.9.x core/modules/node/node.module \node_user_cancel()
  3. 10 core/modules/node/node.module \node_user_cancel()

Implements hook_user_cancel().

File

modules/node/node.module, line 1794

Code

function node_user_cancel($edit, $account, $method) {
    switch ($method) {
        case 'user_cancel_block_unpublish':
            // Unpublish nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array(
                'nid',
            ))
                ->condition('uid', $account->uid)
                ->execute()
                ->fetchCol();
            node_mass_update($nodes, array(
                'status' => 0,
            ));
            break;
        case 'user_cancel_reassign':
            // Anonymize nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array(
                'nid',
            ))
                ->condition('uid', $account->uid)
                ->execute()
                ->fetchCol();
            node_mass_update($nodes, array(
                'uid' => 0,
            ));
            // Anonymize old revisions.
            db_update('node_revision')->fields(array(
                'uid' => 0,
            ))
                ->condition('uid', $account->uid)
                ->execute();
            // Clean history.
            db_delete('history')->condition('uid', $account->uid)
                ->execute();
            break;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.