simple modx api script to remove unwanted users
$dontRem = array('adam','admin'); /* add any additional context you dont wish to have removed here */
$users = $modx->getCollection('modUser');
foreach($users as $user){
$id = $user->get('id');
$name = $user->get('username');
if(!in_array($name,$dontRem)) {
$response = $modx->runProcessor('security/user/delete',array('id'=>$id));
if ($response->isError()) {
echo $response->getMessage() . '<hr/>';
}
else{
echo "removed $id";
}
}
}