delete_users_from_csv.php 831 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. exit;
  4. require __DIR__.'/../../main/inc/global.inc.php';
  5. api_protect_admin_script();
  6. // Define origin and destination courses' code
  7. $debug = true;
  8. $file = 'file.csv';
  9. $users = Import :: csvToArray($file);
  10. foreach ($users as $user) {
  11. //$userInfo = api_get_user_info_from_username($user['UserName']);
  12. $userInfo = api_get_user_info_from_email($user['Email']);
  13. if ($userInfo) {
  14. if ($debug == false) {
  15. UserManager::delete_user($userInfo['user_id']);
  16. echo 'User deleted: '.$userInfo['user_id'].' '.$userInfo['username'].'<br />';
  17. } else {
  18. echo 'User will be deleted: '.$userInfo['user_id'].' '.$userInfo['username'].'<br />';
  19. }
  20. } else {
  21. echo 'user not found: "'.$user['UserName'].'"<br />';
  22. }
  23. }