I'm new to Drupal development and am way over my head on this one. My company runs a subscription-based site offering market research to corporations. A company pays for a subscription and is granted a certain number of users. The person designated as primary user has the ability to add the remaining users themselves. We now need to add a function to allow them to delete a user who is no longer with their company. In doing so, we need the following to happen:
- Delete the record from "users" database table
- Change the author on any node created by the deleted user to "Anonymous"
- Send an email to our internal support address letting them know that the user should be removed from other non-connected systems
The previous developer created a custom module for account management that allows adding users under several different circumstances. For example the user is completely new to the company adding it, which means they need to be added to our other unconnected systems as well, as opposed to providing a Drupal account to a user who is already in our other systems.
Drupal.parseJson to process the request based on the segments of the URL clicked. This was done for the sole reason of being able to update the page with the user list without a complete refresh. I personally don't care if this new function works that way, or if it needs to hit the server and refresh the page. I just need to find a way to do everything in the above list with a single click.
I've looked at the API and found
user_delete, but it requires two params -
$uid. The uid is no problem, but all I can find about
$edit is that it's "an array of submitted form values." We're not using a form, though; our user lists are static text, and the actions all occur onclick of an href (at this point); so there's nothing being submitted. Is there any way I can fake the values of
$edit? Or is there another way to do this? I'm reading about
hook_user() and thinking that I'd call
user_delete() somewhere to do the actual delete, and then my
hook_user() implementation would handle the rest with the
$op = delete param. But before I worry about how to get the other stuff happening, I need some guidance about how to call
Is it even worth it to use
user_delete()? Would it be less trouble to just write my own queries to delete the user record and change any content records to "Anonymous"?