<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$now = new \DateTime();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$UserFactory = $objectManager->get('\Magento\User\Model\UserFactory');
try {
$adminInfo = [
'username' => 'username',
'firstname' => 'firstname',
'lastname' => 'lastname',
'email' => 'yourmail@email.com',
'password' =>'codes@123',
'interface_locale' => 'en_US',
'is_active' => 1
];
$userModel = $UserFactory->create();
$userModel->setData($adminInfo);
$userModel->setRoleId('your_role_id'); // Like 1 , 2 ,3 (set any custom role or administrator)
$userModel->save();
} catch (\Exception $ex) {
echo $ex->getMessage();
exit;
}
echo "User is sucessfully created!";
?>
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$now = new \DateTime();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$UserFactory = $objectManager->get('\Magento\User\Model\UserFactory');
try {
$adminInfo = [
'username' => 'username',
'firstname' => 'firstname',
'lastname' => 'lastname',
'email' => 'yourmail@email.com',
'password' =>'codes@123',
'interface_locale' => 'en_US',
'is_active' => 1
];
$userModel = $UserFactory->create();
$userModel->setData($adminInfo);
$userModel->setRoleId('your_role_id'); // Like 1 , 2 ,3 (set any custom role or administrator)
$userModel->save();
} catch (\Exception $ex) {
echo $ex->getMessage();
exit;
}
echo "User is sucessfully created!";
?>
Comments
Post a Comment