I am trying to make a custom user manipulating tool which will let change user account settings and also delete an account.

When I call this function, I delete the user's who's ID I pass as second parameter, but I also delete the user with id 0.

I don't know what to send for the $edit parameter, so I tryied sending NULL, an empty string, an empty array, but the user account 0 still gets deleted along with the desired one.

Comments

jmlavarenne’s picture

User 0 doesn't get deleted anymore, or maybe that's not what was causing user 0 to get deleted...

But in the message I get notified of two accounts being deleted. The one I am trying to delete, and I also get a blank "has been deleted" message.

  • Someguy has been deleted
  • has been deleted
pembeci’s picture

The code of user_delete ends with:

...
module_invoke_all('user', 'delete', $edit, $account); 

It means if you implemented hook_user in your module, it will be called with 'delete', $edit, and $account as parameters. So if you are deleting the user inside that hook, it will be called again and it may try to delete the user again and return that second message. Actually, this looks like resulting in an infinite loop but may be Drupal prevents it after the first pass.