I get a reasonable number of people on NicaLiving.com who request a login but never actually log in. That is, they have signed up and been sent an activate link but never use it. I would like to delete these accounts if they don't activate them after, say, a week.

Am I missing something that would do this?

Comments

kjv1611’s picture

I have no idea, myself, but I'd like to know about something like this. Surely there is the possibility, or else it wouldn't take much for someone who knows what they're doing to program it..

cog.rusty’s picture

A relatively quick manual method is the admin/user/user page.

Sort users by "status" to get the inactive ones, take a look at their "Member for" and "Last access", and select the ones to be deleted.

rightchoice2c_me’s picture

http://drupal.org/project/inactive_user
you can have a glance on above module although its in drupal 5 but gimme some time if its not been maintaining by any one I'll try my level best to provide drupal 6 version of it.

Work Hard to understand what you have to do b4 U start, You may not be able to develop every detail but the more U know the less risk you take.
http://drupal.coolpage.biz

fyl’s picture

I use that module (site is still D5 but an upgrade is on the list) but that deals with long-term inactivity. I was going to take a look at it to see if I could add this additional functionality but, first, I figured I would ask. There is so much out here it is easy to miss what you need.

ScoutBaker’s picture

Inactive user already has the functionality to both block and delete inactive users. If they haven't ever logged in that should qualify. Plus it gives the reminder e-mails (if you want) to try anfd get them to visit.

I remember something else to delete users as well, but I seem to recall it was D5 also. You can check easily check just the User access/control section of the downloads. Or try Search downloads (turn the block on in your profile).

---
"Nice to meet you Rose...run for your life." - The Doctor
My first public Drupal site - EyeOnThe503

fyl’s picture

I want to delete people who have never logged in after a short time (like 7 days) but notify and eventually block long-term users that have been inactive for a much longer time (like a year). Clearly I could add this to inactive user but just wanted to see if I was missing the obvious answer first.

kjv1611’s picture

This might not would be the best method, but what about writing a SQL statement in the MySQL database that will delete any users that have never been activated, and whose create date is over 7 days (1 week)... then create a Cron task to run that query? Or am I getting too far off the deep end with this thought? It wouldn't require any module (so less memory usage), and would require no additional work from the site admin (you, I'm assuming), once it was done. Of course, I'd definitely recommend testing it first to be sure you have everything sorted out correctly. ;0)

fyl’s picture

That would probably be my choice for "quick and dirty" but it does seem like it would be nice to actually have this happen in a module. I am comfortable with this solution but many would not be.

bharathkumarkn’s picture

Subscribe

Stephen Ollman’s picture

Here is a rule export I created for D7 that deletes all new user accounts that have not logged in since having the account created nor has a role assigned.

It has a 7 day buffer before deleting the accounts.

{ "rules_delete_never_logged_in_accounts_after_1_week_" : {
    "LABEL" : "Delete Never Logged in accounts after 1 week.",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "php", "rules" ],
    "ON" : { "cron" : [] },
    "IF" : [
      { "php_eval" : { "code" : "$expire_time = REQUEST_TIME - 604800; \r\n$found=0;\r\ndrupal_set_message(\u0027Checking for new user accounts that have not logged on within the last 7 days....\u0027);\r\n\r\n $query = db_select(\u0027users\u0027, \u0027u\u0027);\r\n $query-\u003Efields(\u0027u\u0027, array(\u0027uid\u0027))\r\n       -\u003Econdition(\u0027u.uid\u0027, 0,\u0027\u003E\u0027)  \r\n      -\u003Econdition(\u0027u.access\u0027, 0,\u0027=\u0027)\r\n      -\u003Econdition(\u0027u.login\u0027, 0,\u0027=\u0027)\r\n      -\u003Econdition(\u0027u.created\u0027, $expire_time,\u0027\u003C\u0027)\r\n      -\u003Ewhere(\u0027u.uid NOT IN(select uid from {users_roles})\u0027);  \r\n$result = $query-\u003Eexecute();\r\n\r\nwhile($record = $result-\u003EfetchAssoc()) {\r\n   drupal_set_message(\u0027Found user account ID:\u0027.$record[\u0022uid\u0022]);\r\n   user_delete($record[\u0022uid\u0022]);\r\n   ++$found;\r\n}\r\nif($found \u003E= 1) {\r\n  drupal_set_message(\u0027Deleted \u0027.$found.\u0027 accounts\u0027);\r\n}  else {\r\n  drupal_set_message(\u0027No new accounts deleted\u0027);\r\n}\r\n\r\nreturn true;" } }
    ],
    "DO" : []
  }
}

Just copy the code and import it into Rules.

Certified Drupal Site Builder 7 & 8

Stephen Ollman’s picture

For those interested in just the PHP code that is in the rule here it is:

$expire_time = REQUEST_TIME - 604800; 
$found=0;
drupal_set_message('Checking for new user accounts that have not logged on within the last 7 days....');

 $query = db_select('users', 'u');
 $query->fields('u', array('uid'))
       ->condition('u.uid', 0,'>')  
      ->condition('u.access', 0,'=')
      ->condition('u.login', 0,'=')
      ->condition('u.created', $expire_time,'<')
      ->where('u.uid NOT IN(select uid from {users_roles})');  
$result = $query->execute();

while($record = $result->fetchAssoc()) {
   drupal_set_message('Found user account ID:'.$record["uid"]);
   user_delete($record["uid"]);
   ++$found;
}
if($found >= 1) {
  drupal_set_message('Deleted '.$found.' accounts');
}  else {
  drupal_set_message('No new accounts deleted');
}

return true;

Certified Drupal Site Builder 7 & 8

Fawad Ali’s picture

I am trying  to import your code into rules but it gives an error "Missing the required module php."  I did not understand who to figure it out.

I copied the code and past it into rules interface for importing but it gives me an error. "Missing the required module php."

Infinitee’s picture

You need to turn on the Drupal Core  PHP filter (php). 

/admin/modules > Core > PHP filter (php).

Infinitee’s picture

Deleted 37307 accounts in under 5 minutes... Thank you very much!

ashwinsh’s picture

https://www.drupal.org/project/purge_users

Please check this module for deleting inactive users.