Last active
December 12, 2015 10:38
-
-
Save aaronott/4760022 to your computer and use it in GitHub Desktop.
Disable all Drupal users except Admin via Drush
This file contains hidden or 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
#!/usr/bin/env drush | |
<?php | |
# | |
# This script removes all drupal users with uid > 1 (e.g., skips | |
# admin user) and reassigns their content to anonymous. | |
# | |
// check if we can bootstrap | |
$self = drush_sitealias_get_record('@self'); | |
if (empty($self)) { | |
drush_die("I can't bootstrap from the current location.", 0); | |
} | |
// we don't want to say yes each time. | |
drush_set_context('DRUSH_AFFIRMATIVE', TRUE); | |
$result = db_query("SELECT name from {users} WHERE uid > 1"); | |
foreach ($result as $user) { | |
drush_invoke('user-block', array($user->name)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
glopes, sorry for the delay. by now you've no doubt found your solution, but if not you can take a look at one of the other scripts I wrote here: https://gist.github.com/aaronott/6040509 and perhaps that may help.