-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetadmin.php
More file actions
47 lines (30 loc) · 811 Bytes
/
setadmin.php
File metadata and controls
47 lines (30 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
//create new user by providing details below
$user = Mage::getModel('admin/user')
->setData(array(
'username' => 'admin123',
'firstname' => 'Admin',
'lastname' => 'User',
'email' => 'sudheerpal2@gmail.com',
'password' => 'admin@123',
'is_active' => 1
))->save();
//create new role
$role = Mage::getModel("admin/roles")
->setName('Developer')
->setRoleType('G')
->save();
//give "all" privileges to role
Mage::getModel("admin/rules")
->setRoleId($role->getId())
->setResources(array("all"))
->saveRel();
//assign user to role
$user->setRoleIds(array($role->getId()))
->setRoleUserId($user->getUserId())
->saveRelations();
echo 'Admin User sucessfully created!';
?>