How To Create A New Magento Admin Account Programmatically

I would like to create a new Magento admin account, How can I do it programmatically

You need to use ‘admin/user’ model to create a new admin account and assign Magento role to new Magento admin account

$user = Mage::getModel('admin/user')->setData(array(
    'username'  => 'adminusername',
    'firstname' => 'admin first name',
    'lastname'  => 'admin last name',
    'email'     => 'admin@example.com',
    'password'  => 'password',
    'is_active' => 1
))->save();

$user->setRoleIds(array(1)) //Administrator role id is 1
->setRoleUserId($user->getUserId())
->saveRelations();
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments