Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for change admin password
<?php
declare(ticks = 1);
// Mage !
require_once __DIR__ . '/../app/Mage.php';
// Usage function :)
function usage()
{
echo "Usage: php -f " . basename(__FILE__) . " <username>\n";
exit(65);
}
// Check command line
if ($argc != 2) {
usage();
}
// Init Magento
Mage::app('admin');
// Init store (needed for save products for example)
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// We get the user
$user = Mage::getModel('admin/user')->load($argv[1], 'username');
// User exists?
if (!$user->getId()) {
echo "Bad username.\n\n";
usage();
}
// We ask for the password
do {
$password = trim(readline('Wich password?'));
} while (!$password);
// We change the user password :)
$user->setNewPassword($password)->save();
echo "User updated\n";
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment