Magento 1 – Create a user programmatically

Posted on January 29, 2020 by jamie

 <?php 
    require_once('app/Mage.php');
    umask(0);
    Mage::app();
    
    $user = Mage::getModel('admin/user')->setData(array(
             'username' => 'tempuser',
             'firstname' => 'Temp',
             'lastname' => 'User',
             'email' => 'tempuser@floormonster.co.uk',
             'password' => 'apple54tuesday!p',
             'is_active' => 1
         ))
         ->save();

     $user->setRoleIds(array(1))
         ->setRoleUserId($user->getUserId())
         ->saveRelations();
?>