user_manager_drupal6/delete_user.php
Mateusz Gruszczyński c28049d2cf first commit
2025-05-16 11:34:01 +02:00

32 lines
731 B
PHP

#!/usr/bin/env php
<?php
if ($argc < 3) {
echo "Usage: php delete_user.php <UID> <DRUPAL_PATH>\n";
exit(1);
}
$uid = (int) $argv[1];
$drupal_path = rtrim($argv[2], '/');
if (!file_exists($drupal_path . '/includes/bootstrap.inc')) {
echo "❌ Nie znaleziono bootstrap.inc w: $drupal_path\n";
exit(1);
}
define('DRUPAL_ROOT', $drupal_path);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
if ($uid <= 0) {
echo "❌ UID musi być większy niż 0.\n";
exit(1);
}
$account = user_load($uid);
if ($account) {
user_delete($account->uid);
echo "✅ Użytkownik $uid został usunięty.\n";
} else {
echo "⚠️ Użytkownik $uid nie istnieje.\n";
}
?>