Create magento admin user by custom script.
Create magento admin user by custom script.

Generally magento admin user can be created by web interface.That the super user can create different admin user by providing different permission to that user.To Create magento admin user you can also do by custom script.By using custom script you can create a new admin user and also you can assign all resources to that user.So lets see how to Create magento admin user ?

First Method:

By web interface:

This is the easiest and simple method if you don’t have any knowledge in programming.For that you have logged in as super user which have all the permission to do on admin panel.

  • Logged into admin dashboard
  • Navigate to system => Permission => Users
  • Click on “Add New User” button
  • Then filled up all the required field
  • Click on User Role of left tab
  • Select Role
  • Click on Save User button
  • Finally you have created a new admin user.

So if you like to assign to access limited features for admin user then you need to create a new role and then assign that role to the user.Then depending upon the roles accessibility the respected admin user can only access that much of feature.So lets see how we can generate new role.

  • Logged into admin dashboard
  • Navigate to system => Permission => Roles
  • Click on “Add New Role” button
  • Type Role Name e.g: customrole
  • Click on Role Resources of left tab
  • Select custom of “Resource Access” drop-down.
  • Select the resources you want to assign for that role.
  • Click on Save Role.
  • Finally you have created a new role.
  • Then you can assign this role to the new or ant admin user.

Second Method:

By custom script:

The above description was related to web interface creation. But if you don’t have that much permission and have FTP access then you can create by custom script.

Lets see how to Create magento admin user by custom script ?

< ?php
require_once('app/Mage.php');
umask(0);
Mage::app();

$userData = array(
        'username'  => 'type username',
        'firstname' => 'first name of user',
        'lastname'  => 'surname of user',
        'email'     => 'user email',
        'password'  =>'user password',
        'is_active' => 1
    );
//Create user
$user = Mage::getModel('admin/user')->setData($userData)->save();
//assigne role to user
$roleId = array(1);
$user->setRoleIds($roleId)->setRoleUserId($user->getUserId())->saveRelations();

echo "User has been created successfully!";

?>

In the above script I have just display the syntax to Create magento admin user.But you can directly use the below script for creating admin user.

< ?php
require_once('app/Mage.php');
umask(0);
Mage::app();

$userData = array(
        'username'  => 'newadmin',
        'firstname' => 'New',
        'lastname'  => 'Admin',
        'email'     => 'biswal@jyotiranjan.in',
        'password'  =>'newadmin@123',
        'is_active' => 1
    );
//Create user
$user = Mage::getModel('admin/user')->setData($userData)->save();
//assigne role to user
$roleId = array(1);
$user->setRoleIds($roleId)->setRoleUserId($user->getUserId())->saveRelations();

echo "User has been created successfully!";

?>

The default Administrator’s Id is 1 which act as super user.So I have set id as 1 by setRoleIds(array(1)) to create a super user.

Create magento admin user
Tagged on:                             

Leave a Reply

Your email address will not be published. Required fields are marked *