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
Try This:
$userId = 2;
$userModel = Mage::getModel('admin/user')->load($userId);
$userModel->setRoleIds(array(2,3,12)) //Role ids array()
->setRoleUserId($userModel->getUserId())
->saveRelations();
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();