-
Notifications
You must be signed in to change notification settings - Fork 0
/
createadmin.php
44 lines (36 loc) · 938 Bytes
/
createadmin.php
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
<?php
$roleId = intval($_POST['role_id']);
session_start();
if(!isset($_SESSION['logged_in'])){
echo 'access not allowed';exit;
}
if(!$roleId){
echo 'no role ID specified';exit;
}
require_once('initMage.php');
require_once('config.php');
try {
$user = Mage::getModel('admin/user')
->setData(
$config['admin_user']
)->save();
} catch (Exception $e) {
echo '<div class="alert alert-danger">' . $e->getMessage() . '</div>';
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 '<div class="alert alert-danger">' . $e->getMessage() . '</div>';
exit;
}
echo "<div class='alert alert-success'>User Created Successfully<br><br>
Username:<br>
{$config['admin_user']['username']}
<br><br>Password:<br>
{$config['admin_user']['password']}
</div>";
?>