>>
In this blog, we will learn about how to create admin user in Magento 2?. Sometimes we need to create new admin users for different members to provide access to our backend.
There are three ways to create admin user in Magento 2:
1) Create Admin User Via Magento Admin
2) Create Admin User Via Command Line
3) Create Admin User Using PHP Script
Let’s see all three ways in details.
For creating new user using admin panel, then follow below steps:
If you want to use new user role then follow below steps:
-Go to the System→Permissions→User Roles→Add New Role.
Write Role information in the Role Name and Password. In the password, you can set current admin panel password.
In Role Resources Select “Custom” option if you want to provide custom access and select “All” if you want to provide access in all pages.
After fill all information, save role, and you can see your New Role is created. Here we created Sales Role.
Fill Account Information and current admin panel password and then Save User.
After following above steps, you can create Admin User Via Magento Admin Panel.
Another way to create Admin User via command line. In this way, we run follow commands in our Magento root folder:
bin/magento admin:user:create
After run above command it will ask Admin user, Admin password, Admin email, Admin first name and Admin last name.
After fill above fields, you can get ‘Created Magento administrator user named MageAnts’ message, so your admin user will be created.
For create admin user programmatically, you need to create PHP file at Magento root. For example, we create adminuser.php file at Magento root directory and write below code.
<?php |
After create above file, then run command PHP adminuser.php in terminal and create new user in admin.
Here we use username ‘mageants123’ and its password is ‘mageants123’.
Using above article you can easily understand How to Create Admin User in Magento 2 with admin panel, command line and PHP script. If you have any query regarding above code implementation then you can contact us or let us know in comment section.
Sign In
Create New Account