getUserByUsername($username); if (empty($user)) { throw new Exception("User {$username} does not exist - Cannot update account details for unknown user"); } // Update the user's account details using the previous details + WHMCS's details (address, city, state etc.) $userParams = array('RoleId' => $user['RoleId'], 'Role' => $user['Role'], 'StatusId' => $user['StatusId'], 'Status' => $user['Status'], 'LoginStatusId' => $user['LoginStatusId'], 'LoginStatus' => $user['LoginStatus'], 'FailedLogins' => $user['FailedLogins'], 'UserId' => $user['UserId'], 'OwnerId' => $user['OwnerId'], 'IsPeer' => $user['IsPeer'], 'Created' => $user['Created'], 'Changed' => $user['Changed'], 'IsDemo' => $user['IsDemo'], 'Comments' => $user['Comments'], 'LastName' => $clientsDetails['lastname'], 'Username' => $user['Username'], 'Password' => $user['Password'], 'FirstName' => $clientsDetails['firstname'], 'Email' => $clientsDetails['email'], 'PrimaryPhone' => $clientsDetails['phonenumber'], 'Zip' => $clientsDetails['postcode'], 'InstantMessenger' => '', 'Fax' => '', 'SecondaryPhone' => '', 'SecondaryEmail' => '', 'Country' => $clientsDetails['country'], 'Address' => $clientsDetails['address1'], 'City' => $clientsDetails['city'], 'State' => $clientsDetails['state'], 'HtmlMail' => $user['HtmlMail'], 'CompanyName' => $clientsDetails['companyname'], 'EcommerceEnabled' => $user['EcommerceEnabled'], 'SubscriberNumber' => ''); // Execute the UpdateUserDetails method $wsp->updateUserDetails($userParams); // Add log entry to client log logactivity("WebsitePanel Sync - Account {$username} contact details updated successfully", $userId); } catch (Exception $e) { // Error message to log / return $errorMessage = "websitepanel_sync_ClientEdit Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()}, Service ID: {$serviceId})"; // Log to WHMCS logactivity($errorMessage, $userId); } } } /* Update Client Contact Details - WebsitePanel */ add_hook('ClientEdit', 1, 'websitepanel_sync_ClientEdit');