### Create New admin User programmatically. ####
require_once('./app/Mage.php'); umask(0); Mage::app(); try { $user = Mage::getModel('admin/user') ->setData(array( 'username' => '[user_name]', 'firstname' => 'Admin', 'lastname' => 'Admin', 'email' => '[user_email]', 'password' => 'admin123', 'is_active' => 1 ))->save(); } catch (Exception $e) { echo $e->getMessage(); exit; } //Assign Role Id try { //Administrator role id is 1 ,Here you can assign other roles $user->setRoleIds(array(1)) ->setRoleUserId($user->getUserId()) ->saveRelations(); } catch (Exception $e) { echo $e->getMessage(); exit; } echo 'Admin user created successfully';
No comments:
Post a Comment