first commit
This commit is contained in:
32
delete_user.php
Normal file
32
delete_user.php
Normal file
@ -0,0 +1,32 @@
|
||||
#!/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";
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user