1

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

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, privacy policy and cookie policy

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