Hi all!

Following situation:
- site running drupal 5
- user can register at the website and fill out own profiles

I wrote a php-script, that looks, how long each user was inactive and if
the last login is more then 5 weeks in the past, then it mails to me
the direct link to the "Delete User"-dialog - i.e.

Direct link: "http://www.website.de/user/login?destination=user/30/delete"

Then i can remove the user.

But what i want is, that this script removes the user account automatically -
make some querys to the DB and remove appropriating data.
Of course, i could extend a script by adding some another
SQL-queries to delete the data from tables

users
users_roles
profile_values

But i'm sure i could also use the drupal-internal mechanism, to delete
the user without prompting & questioning.

The question now is: HOW?

Or if it isn't possible, entrys in which tables should be deleted manually??

From

users
users_roles
profile_values

or some more?

Thanks!

Comments

toemaz’s picture

First check http://api.drupal.org to find out how to trigger the hook_user to all delete queries in core and contributed modules when a user is being delete.

Second, add a token into you direct link, which makes sure no one can just delete your whole user base. You have to be very careful with these things, so make sure it is secure.

_1313’s picture

As far as i remember, there is a module that can do this job for you. "Advanced User" it is, or something like that.

mooffie’s picture

Have you tried user_delete?

[...] and if the last login is more then 5 weeks in the past, then [...]

Use the last access time, not the last login time.