Created
October 2, 2013 06:16
-
-
Save enminc/6789766 to your computer and use it in GitHub Desktop.
simple modx api script to remove unwanted users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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