Skip to content

Instantly share code, notes, and snippets.

@enminc
Created October 2, 2013 06:16
Show Gist options
  • Save enminc/6789766 to your computer and use it in GitHub Desktop.
Save enminc/6789766 to your computer and use it in GitHub Desktop.
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";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment