I want to delete a user with this code:
$account = User::load(19920);
$account->delete();
How can I do that without also deleting the user’s content?
I’ve been reviewing _user_cancel() hooks, but they all seem to be about doing things in the admin UI.
This hook works the way I expect it to and removes the user_cancel_delete radio button option from the admin UI.
/**
* Implements hook_user_cancel_methods_alter().
*/
function my_user_module_user_cancel_methods_alter(&$methods) {
// Remove Delete the account and its content method.
unset($methods['user_cancel_delete']);
}
but I want to not delete content when $account->delete() is called in my update hook.