and also an role

$roleAuthModel = $objectManager->create('\Magento\Authorization\Model\Role');            
            $roleAuthModel->setName("cool role")
                ->setPid(0) //set parent role id of your role


How can I relate and set "cool role" to my new user "bbbb" ?


You can set role to admin user using role and user models.

/** @var \Magento\Authorization\Model\Role $role */
$role = $this->getRole();
/** @var $model \Magento\User\Model\User */
$user = $this->getUser();


In your case:


Source: \Magento\User\Controller\Adminhtml\User\Save::execute

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.