[support] Help with deleting all users with a specific role

Steve Power steev at initsix.co.uk
Fri Mar 13 06:34:46 UTC 2009


many thanks to everyone

On Thu, Mar 12, 2009 at 9:07 PM, Brett Evanson <brettev at gmail.com> wrote:

> 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
>



-- 
-- 
--
Steve Power
Principal Consultant
Mobile: +44 (0) 7747 027 243
Initsix Technology and Media
--
"So Linux is bulletproof? No. Bulletproof is one of the last stages of
drunkenness, not a state of security"  http://www.linux.com/feature/60208
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/support/attachments/20090313/bccc80f9/attachment.htm>


More information about the support mailing list