1

I need to change the role of the user in case the user fills up all the required details from limited to the administrator. However, I need this to be done programmatically so please guide me the way I can make this possible.

2 Answers 2

0

Try This:

$userId = 2;
$userModel = Mage::getModel('admin/user')->load($userId);
$userModel->setRoleIds(array(2,3,12)) //Role ids array()
        ->setRoleUserId($userModel->getUserId())
        ->saveRelations();
0

This code is for you:

      $role = Mage::getModel("admin/role");
      $role->setParent_id(5); //This is role id
      $role->setTree_level(1);
      $role->setRole_type('U');
      $role->setUser_id($user_id); //user id that role need to change
      $role->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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