[support] Help with deleting all users with a specific role
Brett Evanson
brettev at gmail.com
Thu Mar 12 21:07:07 UTC 2009
if you want to delete the content first, modify code like this:
> $drupal_sql = 'select users.uid from {users} left join {users_roles} on
> users.uid = users_roles.uid
> where rid=4 '; // where 4 is your role
> $r = db_query($drupal_sql);
> while ($row = db_fetch_array($r)) {
$usersnodes = db_query("SELECT nid FROM {node} WHERE uid=%d", $row->uid);
while($usernode = db_fetch_object($usersnodes)){
node_delete($usernode->nid);
}
> user_delete($row->uid);
> }
>
> Sumthin' like that.
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
pretty rough, but i think it'll work
--
Brett Evanson
brettev at gmail.com
More information about the support
mailing list