Adding script see BT#9128

1.9.x
Julio Montoya 10 years ago
parent be8e6ea6db
commit ce28be7ac2
  1. 26
      tests/scripts/delete_users_from_csv.php

@ -0,0 +1,26 @@
<?php
/* For licensing terms, see /license.txt */
exit;
require __DIR__.'/../../main/inc/global.inc.php';
api_protect_admin_script();
// Define origin and destination courses' code
$debug = true;
$file = 'file.csv';
$users = Import :: csv_to_array($file);
foreach ($users as $user) {
//$userInfo = api_get_user_info_from_username($user['UserName']);
$userInfo = api_get_user_info_from_email($user['Email']);
if ($userInfo) {
if ($debug == false) {
UserManager::delete_user($userInfo['user_id']);
echo 'User deleted: '.$userInfo['user_id'].' '.$userInfo['username'].'<br />';
} else {
echo 'User will be deleted: '.$userInfo['user_id'].' '.$userInfo['username'].'<br />';
}
} else {
echo 'user not found: "'.$user['UserName'].'"<br />';
}
}
Loading…
Cancel
Save