//assigns all users to some branch set_time_limit(0); $newUserBranchId=1; //ID of branch to assign with orphans $branches = new UbillingBranches(); $allUsers = zb_UserGetAllData(); if (!empty($allUsers)) { foreach ($allUsers as $userLogin => $userData) { $userCurrentBranch = $branches->userGetBranch($userLogin); //prevent duplicate assigments if (empty($userCurrentBranch)) { $notice = __('Assign') . ' ' . __('Branch') . ' ' . $newUserBranchId . ' ' . __('for') . ' ' . __('user') . ' ' . $userLogin; show_info($notice); //uncomment following line after dry-run tesing for real assign //$branches->userAssignBranch($newUserBranchId, $userLogin); } } }