Skip to content

Instantly share code, notes, and snippets.

@gelanivishal
Created December 25, 2016 02:58
Show Gist options
  • Select an option

  • Save gelanivishal/92e03bd324ccf9af61ce707699f90f6c to your computer and use it in GitHub Desktop.

Select an option

Save gelanivishal/92e03bd324ccf9af61ce707699f90f6c to your computer and use it in GitHub Desktop.
M1: Create admin user (External script)
<?php
require_once('./app/Mage.php');
umask(0);
Mage::app();
try {
$user = Mage::getModel('admin/user')
->setData(array(
'username' => 'developer',
'firstname' => 'John',
'lastname' => 'Smith',
'email' => 'john@example.com',
'password' =>'admin123',
'is_active' => 1
))->save();
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
//Assign Role Id
try {
$user->setRoleIds(array(1)) //Administrator role id is 1 ,Here you can assign other roles ids
->setRoleUserId($user->getUserId())
->saveRelations();
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
echo "User created successfully";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment