├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── hooks
├── AbortEmailSendingBasedOnUserIDClientGroupID.php
├── AcceptOrderOnInvociePaid.php
├── AcceptQuoteWithoutLogin.php
├── AddButtonNextToModulesFunctions.php
├── AdminStatsForWHMCSv8.php
├── AnnuncementsMetaDescription.php
├── AssignClientToGroupBasedOnPurchasedProduct_v1.php
├── AssignClientToGroupBasedOnPurchasedProduct_v2.php
├── AssignClientToGroupBasedOnRegisteredDomains.php
├── AssignClientToGroupBasedOnRegistrationDate.php
├── AutoLoginToAnyPanelFromMyServices.php
├── AutoTerminateFreeTrialsAfterXMinutes.php
├── BanOrderExpiration.php
├── BulkAutoRecalculateClientDomainsProducts.php
├── CancelOrderOnInvoiceCancelled.php
├── ChangeDefaultSortingBackendTables.php
├── ChatstackDisableLoggedInAndAdmin.php
├── ClientGroupColorInTicketView.php
├── ConditionalClientCustomFieldsBasedOnSelectedCountry.php
├── ConditionalSupportDepartments.php
├── ContactsEmailConfirmation.php
├── CouponCodeInEmailTemplate.php
├── DailyCronJonOnDemand.php
├── DisableFeedbackRequestsForUnansweredTickets.php
├── ExemptExistingClientsFromAffiliateCommissions.php
├── ForcePaymentGatewayDependingOnInvoiceBalance.php
├── GenerateUUID.php
├── HideGoogleInvisibleReCAPTCHA.php
├── IfClientsGroupThisThenThat.php
├── InactiveIsTheNewActive.php
├── KnowledgebaseAuthor.php
├── KnowledgebaseLastUpdatedDate.php
├── LoginAsClientPreserveLanguage.php
├── NewClientsAsAffiliates.php
├── NoteInTheOrderAbortAutoProvisioning.php
├── NotifyFradulentOrders.php
├── OneOffProductsDomainRequireProduct.php
├── PreventAccessToBackendDuringMaintenance.php
├── PreventChangesToClientCustomFields.php
├── PreventEmailSendingBasedOnClientGroup.php
├── PreventSearchEngineIndexing.php
├── PromotionsArrayInEmailTemplates.php
├── QuoteToInvoiceNoRedirect.php
├── RelatedServiceInInfoTicketSidebar.php
├── RemoveIPAddressFromViewTicketClientArea.php
├── RemovePortalHomeBreadcrumb.php
├── RenameAddonModuleLabel.php
├── RestrictDomainBillingCyclesBasedOnTLD.php
├── RestrictPaymentGatewaysBasedOnClientGroup.php
├── SendEmailAndAddReplyOnTicketStatusChange.php
├── StrongerPasswordGeneratorForAutoProvisioning_v1.php
├── StrongerPasswordGeneratorForAutoProvisioning_v2.php
├── StrongerPasswordGeneratorForAutoProvisioning_v3.php
├── TicketFeedbackEscalationRule.php
├── UpdateAdminLinksWhenCustomAdminPathChanges.php
└── noDatesInInvoiceItemsDescription.php
├── modules
└── addons
│ └── PleskChecker
│ ├── PleskChecker.php
│ ├── core
│ ├── Katamaze
│ │ ├── Checker.php
│ │ ├── PleskAPIClient.php
│ │ └── index.php
│ └── index.php
│ ├── images
│ ├── index.php
│ └── katamaze.png
│ ├── index.php
│ └── templates
│ ├── Admin
│ ├── Main.tpl
│ └── index.php
│ └── index.php
└── reports
└── Churn_Rate.php
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: '[Bug]'
5 | labels: 'bug'
6 | assignees: 'Kian987'
7 |
8 | ---
9 |
10 | ## Before reporting a bug
11 | Make sure you're running the most up-to-date version of the action hook.
12 |
13 | ## Action Hook File Name
14 | We created a lot of action hooks hence knowing the name of the hook that is causing you a problem is mandatory. Hook name corresponds to file name (eg. `AcceptOrderOnInvociePaid.php`, `DailyCronJonOnDemand.php`).
15 |
16 | ## Describe the Bug
17 | A clear and concise description of what the bug is.
18 |
19 | ## To Reproduce
20 | Steps to reproduce the behavior:
21 | 1. Go to '...'
22 | 2. Click on '....'
23 | 3. Scroll down to '....'
24 | 4. See error
25 |
26 | ## Expected behavior
27 | A clear and concise description of what you expected to happen.
28 |
29 | ## Affected Version
30 | Please complete the following information:
31 |
32 | * WHMCS [eg. 7.10.2]
33 | * PHP [eg. 7.2.32]
34 |
35 | ## Screenshots
36 | If applicable, add screenshots to help explain your problem.
37 |
38 | ## Additional context
39 | Add any other context about the problem here.
40 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: '[Feature Request]'
5 | labels: 'feature request'
6 | assignees: 'Kian987'
7 |
8 | ---
9 |
10 | ## Before requesting a feature
11 | We're in the process to transition from completely closed to completely open source. Before taking this important step, we're using this project to show our intent by releasing hundreds of scripts for WHMCS 100% free.
12 |
13 | Recently we started re-routing some presales from [our site](https://katamaze.com/) here on Github. Basically we're willing to code solutions for free. The only requirement is that we're open for **small and medium-sized projects** that are not in contrast with [what we are selling](https://katamaze.com/whmcs).
14 |
15 | Let's start!
16 |
17 | ## Describe the solution you'd like
18 | A clear and concise description of what you want to happen in your WHMCS.
19 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at info@katamaze.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | First off, thanks for taking the time to contribuite 👍
4 |
5 | The point of this this package is to help **Developers**, **Hosting Providers**, **Web Agencies** and **IT professionals** to perfect WHMCS. Over the years we kept improving our code based on customers' feedback but together we can make it even better.
6 |
7 | Feel free to propose changes to existing scripts, request new action hooks and report bugs.
8 |
9 | Please read the following FAQ to know more about coding conventions.
10 |
11 | # Frequently Asked Question
12 |
13 | ## Why do you keep using `ClientAreaPage` when a more specific hook point is available?
14 |
15 | For us backward compatibility has always been important since we have customers still running outdated versions of WHMCS (it doesn't depend on us ☹️). That said, we know we can use `ClientAreaPageHome` in place of `ClientAreaPage` to "play" with home page. The problem is that older versions of WHMCS only have `ClientAreaPage`. That's why we keep using it.
16 |
17 | ## Can I use short open tag ``
18 |
19 | Nope. Some servers don't support it so we don't use it. Recap:
20 |
21 | * Start with ``
23 |
24 | ## Can I place `use` operator wherever I need?
25 |
26 | No. All `use` statements must be on top of the file right after `
142 |
143 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/ConditionalClientCustomFieldsBasedOnSelectedCountry.php)
144 |
145 | ## Prevent Admins from accessing WHMCS backend during Maintenance
146 |
147 | Define an array of Admin and/or Admin Roles that are allowed to access WHMCS backend when Maintenance Mode is enabled. All other Admins are logged out automatically.
148 |
149 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/PreventAccessToBackendDuringMaintenance.php)
150 |
151 | ## If client's group this than that
152 |
153 | Over the years I coded hundreds of hooks involving WHMCS client's group. It is common that people want to tie very specific logic to groups. The hook that I am going to present you can be used as starting point to begin playing with WHMCS client groups.
154 |
155 | I got inspiration from [IFTTT](https://ifttt.com/explore/new_to_ifttt) (If This Then That). It all starts from the initial array where you define what should happen for every client group of WHMCS. My initial version lets you apply the following rules/actions to given client groups:
156 |
157 | * Enable/disable tax exempt status
158 | * Replace `Pay to` text of invoices with anything you want
159 | * Define an array of allowed payment methods. This implies that other payment methods are restriced
160 |
161 | In the example you find in the script, I prepared the following scenario:
162 |
163 | * Clients belonging to group id `1`:
164 | * Tax exempt: Enabled
165 | * Default Invoice header (Pay To) replaced with `Ferrari S.p.A. ...`
166 | * Allowed payment methods: `paypalcheckout` (default), `banktransfer`. All other payment methods get automatically removed from open invoices (not in `Paid`, `Collections`, `Refund`, `Payment Pending` status). Moreover the script also removes them from `Payment Method` dropdown accessible from `viewinvoice.php`
167 | * Clients belonging to group id `2`:
168 | * Tax exempt: Disabled
169 | * Default Invoice header (Pay To) replaced with `Juventus S.p.A. ...`
170 | * Allowed payment methods: `banktransfer` (default). Same principle previously described. Other gateways get restricted from open invoices and dropdown
171 |
172 | You can extend this hook to meet your specific goals. For example you could add conditional invoice logo rather than currency, language, email preferences etc.
173 |
174 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/IfClientsGroupThisThenThat.php)
175 |
176 | ## Restrict payment gateways based on client group
177 |
178 | As the title says, define what payment gateways each client group is allowed to use to pay invoices. The hook automatically removes restricted payment gateways from `viewinvoice.php` page (Paymeth Method dropdown menu). It also replaces restricted gateways from open invoices (not in `Paid`, `Collections`, `Refund`, `Payment Pending` status) with the first gateway you defined in `allowed_payment_gateways` array.
179 |
180 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/RestrictPaymentGatewaysBasedOnClientGroup.php)
181 |
182 | ## Admin Stats for WHMCS v8
183 |
184 | As you probably know WHMCS v8 no longer provides statistics on top of the page about pending orders, overdue invoices and tickets awaiting reply. This action hook adds them back to interface as you can see from the following screenshot.
185 |
186 | 
187 |
188 | 
189 |
190 | The one thing you can customize is `$showZero` variable. Let's focus on the *0 Ticket(s) Awaiting Reply* badge of above images. If `$showZero` is set to `false`, the widget doesn't show this specific badge.
191 |
192 | This widget is fully responsive and appears if there's at least one pending order, overdue invoice or ticket awaiting reply. If there's nothing to show it disappears. To avoid any possibility of confusion, the hook automatically detects if you're running v8.
193 |
194 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/AdminStatsForWHMCSv8.php)
195 |
196 | ## Client Group Color in Ticket View for WHMCS v8
197 |
198 | Client group background colors no longer display on ticket view page. Go figure out why WHMCS decided to remove it from v8. This action hook puts the styling back.
199 |
200 | 
201 |
202 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Scripts/blob/master/hooks/ClientGroupColorInTicketView.php)
203 |
204 | ## Simulate / Run WHMCS Daily Cron Job on Demand
205 |
206 | As the name suggests, WHMCS daily cron job runs once per day. There's no easy way to make it run multiple times. This could be frustrating in case you're coding or testing new features that's where this hook comes to help.
207 |
208 | 
209 |
210 | The hook adds *Run Daily Cronjob* button (the orange one) on top of your WHMCS Administration. Clicking it allows to run WHMCS daily cron job whenever you want. All it takes is a click. Please, ignore *Reinstall* and *Manage Demo* buttons. We use them for [Live Demo](https://katamaze.com/demo) to let visitors try our modules before purchase.
211 |
212 | Be advised that on WHMCS v8 and newer versions the *Run Daily Cronjob* button is placed on top of the sidebar as shown in the screenshot.
213 |
214 | 
215 |
216 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/DailyCronJonOnDemand.php)
217 |
218 | ## Accept Quote without Logging In
219 |
220 | When you send a quote, WHMCS forces customers to login in order to accept it. This hook allows them to accept without the need to login. Every time the *Quote Delivery with PDF* mail is sent, the hook overrides `{$quote_link}` with a new link that contains an hash that ensures the authenticity of the request. This way only the recipient can accept the quote.
221 |
222 | When the visitor clicks the link, the quote is automatically accepted and he/she sees the following modal on screen.
223 |
224 | 
225 |
226 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/AcceptQuoteWithoutLogin.php)
227 |
228 | ## Bulk Auto Recalculate Client Domain & Products/Services
229 |
230 | Yes, WHMCS integrates [Bulk Pricing Updater](https://docs.whmcs.com/Bulk_Pricing_Updater_Addon) but it works for all existing customers. Sometimes you simply need to recalculate prices for domains and products/services of a specific customer. This hook allows to do that in one click. First it adds the following button in client Summary.
231 |
232 | 
233 |
234 | Second it shows this modal on screen where you can freely choose to auto-recalculate domains or products/services.
235 |
236 | 
237 |
238 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/BulkAutoRecalculateClientDomainsProducts.php)
239 |
240 | ## No Dates in Invoice Items Description
241 |
242 | When it comes to service/domain renewal, WHMCS always puts dates in invoice description like so `Hosting Silver - example.com (10/05/2022 - 09/05/2023)`. With this hook you can get rid of the ` (10/05/2022 - 09/05/2023)` part (initial space included). The hook automatically detects what is the Date Format in use on your WHMCS:
243 |
244 | * `DD/MM/YYYY`
245 | * `DD.MM.YYYY`
246 | * `DD-MM-YYYY`
247 | * `MM/DD/YYYY`
248 | * `YYYY/MM/DD`
249 | * `YYYY-MM-DD`
250 |
251 | This way it always uses the right regex to match the string. The hook triggers on `InvoiceCreationPreEmail` hence it will not affect your existing invoices. Lastly it works also with multiple-lines descriptions (eg. addons, configurable options).
252 |
253 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/noDatesInInvoiceItemsDescription.php)
254 |
255 | ## cPanel & Plesk login button in My Services
256 |
257 | Managing multiple hosting accounts could be frustrating for customers. The following hook makes things easier allowing them to login to any control panel directly from My Services list. Here's the preview.
258 |
259 | 
260 |
261 | The hook works with any panel (cPanel, Plesk, DirectAdmin, Centova Cast...) provided that servers and products/services have been intgrated correctly. Before you get the code, keep in mind that this action hook requires some changes to a template file.
262 |
263 | Open `templates/{YOUR_TEMPLATE}/clientareaproducts.tpl` and add the new *Manage* column in `thead` like follows.
264 |
265 | ```
266 |
267 |
268 |
{$LANG.orderproduct}
269 |
{$LANG.clientareaaddonpricing}
270 |
{$LANG.clientareahostingnextduedate}
271 |
{$LANG.clientareastatus}
272 |
{$LANG.manage}
273 |
274 |
275 |
276 | ```
277 |
278 | Your `thead` could be slightly different (eg. your first column could be the SSL icon check) so change things accordingly. Next move to `tbody` and add the cell right inside `{foreach}` loop.
279 |
280 | ```
281 |
282 | {if $kt_autologin[$service.id]}
283 |
284 |
285 |
286 | {/if}
287 |
288 | ```
289 |
290 | We suggest you to replace *Click to Login* with `$LANG` variable for multi-language support. Now we need to disable sorting for the newly added column. On top of the file you'll find the following statement.
291 |
292 | ```
293 | {include file="$template/includes/tablelist.tpl" tableName="ServicesList" noSortColumns="4" filterColumn="3"}
294 | ```
295 |
296 | Focus on `noSortColumns="4"`. *4* means that the 5th column will be not sortable (column count start from zero). Change it accordingly. For example if your template uses the SSL check as 1st column, use `noSortColumns="0, 5"`.
297 |
298 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/AutoLoginToAnyPanelFromMyServices.php)
299 |
300 | ## Related Service in Ticket Sidebar
301 |
302 | Customers can specify the related service/domain on ticket submission but once the ticket has been sent the information is no longer visible. This hook makes sure that related service is always included in ticket sidebar (if specified).
303 |
304 | 
305 |
306 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/RelatedServiceInInfoTicketSidebar.php)
307 |
308 | ## Force Payment Gateway depending on Invoice Balance
309 |
310 | It doesn't matter what payment method you use. It can be PayPal, Stripe, Skrill or Credit Card. The typical gateway charges absurdly high fees to manage your money. [Billing Extension](https://katamaze.com/whmcs/billing-extension/specifications) helps you [saving up to 18% on transaction fees](https://katamaze.com/docs/billing-extension/4/reducing-the-number-of-invoices#OnePayment) but such costs can be lowered even further.
311 |
312 | Let's face it. In an ideal world we would be receiving money just with Bank Transfer (aka Wire Transfer) since it doesn't cost you anything. The following hook can be used to force the most convenient gateway you have depending on invoice balance. For example *if invoice balance >= 1000 euro force banktransfer*. Let's do some math.
313 |
314 | * PayPal charges 3.4% + 0.35 € per transaction meaning that receiving 1000 € costs you 35.35 €
315 | * Let's suppose on a yearly basis you receive 10 payments of 1000 €
316 | * At the end of the year you gave to PayPal 353.5 €
317 |
318 | With this hook you can keep this money for you. As if it wasn't enough, the hook can be customized to force the payment gateway depending on customers' country. For example you can use the hook just for specific countries (eg. IT, FR, DE) and/or European Union. Don't worry about multiple currencies. The script automatically handles currency conversion when needed.
319 |
320 | It is worth to say that the hook allows administrators to lift restrictions on specific invoices. All you all you need is changing the payment method from `Options` tab (Invoice View). This will add the following note `Payment Method Unlocked by Administratror` that serves as a way to let customers freely choose their gateway.
321 |
322 | Of course we don't want such note to be visible in front-end hence the hook automatically removes it from the HTML version invoices. As for the PDF version, you'll need to place a small piece of code right above `if ($notes)` statement in your `invoicepdf.tpl` as follows:
323 |
324 | ```
325 | # Notes
326 | $notes = str_replace('Payment Method Unlocked by Administratror', '', $notes);
327 | $notes = ($notes ? $notes : false);
328 | if ($notes) {
329 | $pdf->Ln(5);
330 | $pdf->SetFont($pdfFont, '', 8);
331 | $pdf->MultiCell(170, 5, Lang::trans('invoicesnotes') . ': ' . $notes);
332 | }
333 | ```
334 |
335 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/ForcePaymentGatewayDependingOnInvoiceBalance.php)
336 |
337 | ## Auto-Terminate Free Trials After X Minutes
338 |
339 | Free trials for a limited period is a good marketing strategy to capitalize on the leads you get. The problem with trials is that the smallest unit of time for WHMCS is the day meaning that for example you can't provide a trial for VPS that last for a couple of hours. WHMCS can't "think" for a period of less than a full day.
340 |
341 | The following action hook allows to automatically terminate or suspend the given products/services after a certain number of minutes. It runs AfterCronJob hook point that normally triggers once every 5 minutes. Visit Setup > Automation Settings and make sure that cron.php runs every 5 minutes as suggested by WHMCS. The hook will do the rest. It also logs performed actions in Activity Log. Here are the variables you need to configure:
342 |
343 | * `$productIDs` array of Product ID you want to terminate or suspend
344 | * `$terminateAfter` terminate or suspend products after the given number of minutes (1440 = full day - 0 to disable) `integer`
345 | * `$performAction` can choose between `Terminate` and `Suspend`
346 |
347 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/AutoTerminateFreeTrialsAfterXMinutes.php)
348 |
349 | ## Stronger Password Generator for Auto-Provisioning
350 |
351 | We give you not one, not two but three action hooks to override default passwords generated by WHMCS for service provisioning on third-party control panels like Plesk, cPanel, DirectAdmin and custom-made server modules.
352 |
353 | * [v1](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/StrongerPasswordGeneratorForAutoProvisioning_v1.php) randomly picks 10 characters from `a-zA-Z0-9` and `!@#$%^&*()-=+?`
354 | * [v2](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/StrongerPasswordGeneratorForAutoProvisioning_v2.php) same as above but makes sure that at least one special character is included in the password
355 | * [v3](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/StrongerPasswordGeneratorForAutoProvisioning_v3.php) for extremely strong passwords. Individually define the number of digits, lowercase, uppercase and special characters to use. The resulting password will not use the same character twice
356 |
357 | ## One-off Products/Services & Domain purchase requires Product/Service
358 |
359 | If you have a bit of experience with WHMCS, you know that offering promotions just via [coupon codes](https://docs.whmcs.com/Promotions) isn't so flexible.
360 |
361 | Many prefer to have products/services created specifically for special deals. Similarly others want to restrict domain purchase to customers with at least a product/service in their accounts. The hook lets you achieve both goals. Simply configure the following variables:
362 |
363 | * `kt_onetimeProducts` array of product IDs to treat as "one-off" (customer is not allowed to order the same product multiple times)
364 | * `kt_onetimeProductGroups` same as above but for product group IDs. Producs inside such groups are treated as one-off
365 | * `kt_firstTimerTollerance` product-based restrictions are disabled for new customers placing their first order with you
366 | * `kt_notRepeatable` if a customer already has a one-off product, he can't purchase further one-offs (`kt_firstTimerTollerance` is ignored)
367 | * `kt_domainRequiresProduct` domain purchase is allowed only if any of the following conditions is met:
368 | * Customer has an existing product/service (`Pending` and `Terminated` don't count)
369 | * Customer is purchasing a domain and a product/service
370 | * `kt_onClientRegister` ordering one-off products is possible only for clients who registered within the last X number of days (`int`). Leave `false` to disable
371 | * `kt_promptRemoval` notify customer about restrictions via (previews are below):
372 | * `bootstrap-alert` right below *Review & Checkout*
373 | * `modal` on screen
374 | * `js-alert` on scren
375 | * `kt_textDisallowed` message displayed for product-based restriction
376 | * `kt_textRequireProduct` message displayed for domain-based resrticion
377 |
378 | When the hook detects that the customer is not allowed to order specific products/services and/or domains, it removes them from WHMCS cart showing alerts.
379 |
380 | 
381 |
382 | The script highlights products/services used for promotions in green and with "promo" label.
383 |
384 | 
385 |
386 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/OneOffProductsDomainRequireProduct.php)
387 |
388 | ## New Clients as Affiliates
389 |
390 | Automatically sets newly registered customers as Affiliates on WHMCS. This way they don't need to join manually.
391 |
392 | That said, as you probably already know the affiliate system of WHMCS is very basic. If you need something more complete and sophisticated take a look at [Commission Manager](https://katamaze.com/whmcs/commission-manager/specifications).
393 |
394 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/NewClientsAsAffiliates.php)
395 |
396 | ## Send Email & Add Reply on Ticket Status Change
397 |
398 | When the status of a support ticket changes, WHMCS doesn't send any notification. We can tweak this process by sending an email and optionally also automatically add a reply to the ticket itself. This way you can guide customers through the resolving process letting them track the progress of tickets.
399 |
400 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/SendEmailAndAddReplyOnTicketStatusChange.php)
401 |
402 | ## Ticket Feedback on Auto Close via Escalation Rule
403 |
404 | Sending [feedback request](https://docs.whmcs.com/Support_Tab#Ticket_Closure_Feedback_Request) on ticket closure is a great way to measure customer support satisfaction however this feature has a missing piece. A ticket in WHMCS can be set as `Closed` in three different ways:
405 |
406 | * When the ticket is closed by an admin user
407 | * For inactivity `Setup > Automation Settings > Support Ticket Settings > Close Inactive Tickets`
408 | * Via [escalation rules](https://docs.whmcs.com/Support_Ticket_Escalations)
409 |
410 | WHMCS doesn't send any feedback request when the ticket is closed with an escalation rule. The hook in question solves this problem. The only requirements are the following:
411 |
412 | * `$cronFrequency` must be equal to your [System Cron Frequency](https://docs.whmcs.com/Crons#System_Cron)
413 | * You must use unique names for escalation rules
414 |
415 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/TicketFeedbackEscalationRule.php)
416 |
417 | ## Disable Feedback for Unanswered Tickets
418 |
419 | WHMCS always sends feedback requests for closed tickets, no matter what. This includes the case of customers closing tickets before you even had the chance to add a reply. For example a customer opens a ticket to report an error on his website. Few minutes later he realizes that it was his fault and closes the ticket. WHMCS still sends feedback request.
420 |
421 | This is quite strange as you are asking customers to let you know the *«Quality of experience»* with your support team. No one has even answered! Some customers could even give you a very bad rating because they feel you're tricking them. Let's patch the hole with this hook.
422 |
423 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/DisableFeedbackRequestsForUnansweredTickets.php)
424 |
425 | ## Client to Group based on Purchased Items
426 |
427 | Automatically assign customers to a client group based on purchased product/service, product addon and configurable options. It works only for customers that haven't been assigned to any group yet. Below we're going to show you how to define group/product pairs. Let's take this code as example.
428 |
429 | ```
430 | $groups['products']['1'] = array('1', '2', '3');
431 | $groups['products']['2'] = array('4');
432 | $groups['productaddons']['1'] = array('2');
433 | $groups['configurableoption']['3'] = array('5' => true, '6' => array('7', '8', '10'));
434 | ```
435 |
436 | The key of the first level of `$groups` array (eg. `['products']`) can assume the following values:
437 |
438 | * `products` for group/product pairs
439 | * `productaddons` for group/product addon pairs
440 | * `configurableoption` for group/configurable option paris
441 |
442 | The key of the second level of `$groups` array (`['1']`, `['2']`) represents the client group ID. `array()` stores product IDs, product addon IDs and configurable options. Let's put it into practice explaining what the above configuration means:
443 |
444 | * Customer A purchases product `1`. He goes to client group ID `1`
445 | * Customer B purchases product `2`. He still goes to client group ID `1`
446 | * Customer C purchases product `4`. He goes to client group ID `2`
447 | * Customer D purchases product `5`. No action taken
448 | * Customer E purchases product `1` and is already assigned to a client group. No action taken
449 | * Customer F purchases product addon `2`. He goes to client group ID `1`
450 | * Customer G purchases a product selecting any value of configurable option ID `5`. He goes to client group ID `3`
451 | * Customer H purchases a product selecting specifically `7`, `8` or `10` options of configurable option ID `6`. He goes to client group ID `3`
452 |
453 | The script is available in two versions. The configuration is the same. What changes is the hook point:
454 |
455 | * [AcceptOrder version](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/AssignClientToGroupBasedOnPurchasedProduct_v1.php) assigns the group when the order is accepted - both manually and automatically
456 | * [EmailPreSend version](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/AssignClientToGroupBasedOnPurchasedProduct_v2.php) assign the group a moment before WHMCS sends the `Welcome Email` - any type (eg. Hosting, VPS, CodeGuard, Marketgoo...). This way the group just assigned is immediately ready for use in email templates
457 |
458 | ## Client to Group based on Registration Date
459 |
460 | This hook is similar to the one that [assigns clients to groups based on purchases](#client-to-group-based-on-purchased-items). This time we're assigning clients to groups based on registration date or more precisely on *user seniority*. Let's take this code as example.
461 |
462 | ```
463 | $groups['1'] = '90';
464 | $groups['2'] = '180';
465 | $groups['3'] = '365';
466 | ```
467 |
468 | The key of `$groups` array (eg. `['1']`) represents the ID of the group while the value *user seniority* (days between registration date and current date). According to the above configuration, here is what happens:
469 |
470 | * Customer A registered `34` days ago. No change
471 | * Customer B registered `90` days ago. He goes to client group ID `2`
472 | * Customer C registered `364` days ago. Still group ID `2`
473 | * Customer D registered `500` days ago. He goes to client group ID `3`
474 |
475 | The hook runs with WHMCS daily cron job meaning that tomorrow the customer C of the above example will move from group `2` to `3`. Optionally, you can turn on any of the following features to add some restrictions:
476 |
477 | * `$activeCustomers` rules apply only on `Active` customers (boolean `true` or `false`)
478 | * `$oldestPurchase` rules apply only on if customer has a product/service or domain older than the given number of days (`integear`)
479 | * `$ignoreDomains` set `true` to ignore domain purchases when `$oldestPurchase` is in use
480 | * `$ignoreProducts` array of product IDs to ignore when `$oldestPurchase` is in use
481 |
482 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/AssignClientToGroupBasedOnRegistrationDate.php)
483 |
484 | ## Client to Group based on Registered Domains
485 |
486 | The hook assigns clients to groups based on the number of active domains in their accounts (`Active`, `Grace` and `Redemption`). This is particularly useful for [Domain Pricing slabs](https://docs.whmcs.com/Client_Groups#Domain_Pricing_Slabs). Let's take this code as example.
487 |
488 | ```
489 | $groups['1'] = '10';
490 | $groups['2'] = '25';
491 | $groups['3'] = '100';
492 | ```
493 |
494 | The key of `$groups` array (eg. `['1']`) represents the ID of the group while the value the number of active domains. According to the above configuration, here is what happens:
495 |
496 | * Customer A has `10` domains. He goes to client group ID `2`. Next day domains become `9`. The the customer is removed from the group
497 | * Customer B has `99` domains. He still goes to client group ID `2` but will be moved to `3` in case he manages to reach `100` domains
498 | * Customer C has `250` domains. Group ID `3`
499 |
500 | The hook runs with WHMCS daily cron job meaning that customers are moved (or removed) from groups on a daily basis. Optionally, you can use the following feature to add some restrictions:
501 |
502 | * `$activeCustomers` rules apply only on `Active` customers (boolean `true` or `false`)
503 | * `$placeholderGroup` used to restrict assignments to a specific group (group ID or `false` to disable). This option requires further explanation as detailed below
504 |
505 | Let's assume we use the following configuration.
506 |
507 | ```
508 | $groups['1'] = '10';
509 | $groups['2'] = '25';
510 | $groups['3'] = '100';
511 |
512 | $placeholderGroup = '5';
513 | ```
514 |
515 | The hook processes assignments only on clients assigned to group ID `5` (the placeholder), `1`, `2` and `3`. Let's see some examples:
516 |
517 | * Customer A has `250` domains and is assigned to group `5`. After cron job he's moved to group `3`
518 | * Customer B has `10` domains and is assigned to group `1` and transfers away one domain. After cron job he's moved to group `5` as now he owns only `9` domains
519 |
520 | The placeholder can also be one of the existing group as in the following example:
521 |
522 | ```
523 | $groups['1'] = '10';
524 | $groups['2'] = '25';
525 | $groups['3'] = '100';
526 |
527 | $placeholderGroup = '1';
528 | ```
529 |
530 | In this case the `10` domains requirement for group `1` is ignored. The hook keeps track of changes to clients' group in the Activity Log.
531 |
532 | 
533 |
534 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/AssignClientToGroupBasedOnRegisteredDomains.php)
535 |
536 | ## Exempt Existing Clients from Affiliate Commissions
537 |
538 | If a visitor places an order for a product or service with the [affiliation cookie](https://docs.whmcs.com/Affiliates) present, the affiliate earns a commission. The problem is that for WHMCS visitors and customers are the same thing meaning that it gives commissions to affiliates even for orders placed by existing customer.
539 |
540 | The hook prevents WHMCS from paying commission for customers registered on your from a given number of days. For example if you set `$numberOfDays = '30'`, WHMCS stops paying commissions for new orders placed by customers registered from more than 30 days on your site.
541 |
542 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/ExemptExistingClientsFromAffiliateCommissions.php)
543 |
544 | ## Prevent changes to Client Custom Fields
545 |
546 | WHMCS has an in-built function to lock client profile fields you want to prevent clients being able to edit from clientarea (eg. email, company name). This feature however is not avaiable for client custom fields. Making such fields "disabled" via HTML is not an option. Anyone with bit of HTML knowledge can skip this form of protection.
547 |
548 | This hook acts as the last line of defense. It grants that no customer can submit changes. If necessary it can be enabled also for WHMCS Administrators.
549 |
550 | If you need something more professional, [Billing Extension](https://katamaze.com/whmcs/billing-extension) can bring your WHMCS to the next level with things like [monthly invoicing](https://katamaze.com/docs/billing-extension/4/reducing-the-number-of-invoices), electronic invoicing, [customer retention](https://katamaze.com/docs/billing-extension/39/client-area#Customer-Retention), [Facebook Pixel](https://katamaze.com/docs/billing-extension/43/facebook-pixel) and much more.
551 |
552 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/PreventChangesToClientCustomFields.php)
553 |
554 | ## Quote to Invoice conversion without redirect
555 |
556 | If you are sending out a lot of quotes on a daily basis, the fact that WHMCS forces a redirect to the newly issued invoice could be frustrating. This hook prevents WHMCS from performing the redirect allowing you to keep woriking on the quote.
557 |
558 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/QuoteToInvoiceNoRedirect.php)
559 |
560 | ## Remove/Hide Breadcrumb
561 |
562 | WHMCS prepends *Portal Home* to breadcrumb. There's nothing wrong with that but some people don't like it. This hook removes it from all WHMCS pages.
563 |
564 | Bonus tip: if you don't want to use an action hook, you can use the following CSS. The result is the same.
565 |
566 | ```
567 | .breadcrumb li:first-child {
568 | display:none;
569 | }
570 | .breadcrumb li:nth-child(2):before {
571 | content:" ";
572 | }
573 | ```
574 |
575 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/RemovePortalHomeBreadcrumb.php)
576 |
577 | ## Knowledgebase Author
578 |
579 | WHMCS doesn't store any information about author - the administrator who published a KB article. This hook automatically adds a new column in `tblknowledgebase` named `kt_author` (the `kt_` prefix is important to avoid naming collision). When an admin adds an article to KB the same hook stores author information and shows it on screen.
580 |
581 | 
582 |
583 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/KnowledgebaseAuthor.php)
584 |
585 | ## Knowledgebase Last Updated Date
586 |
587 | WHMCS doesn't store *Last Updated* date when you edit Knowledgebase articles but you can retreive from Activity Log. It's not a stylish solution but it works. The hook adds `lastupdated` element to the existing `$kbarticle` Smarty array. Once done, change your KB template accordingly.
588 |
589 | If you're looking for something more professional and up to date, learn how to benefit from [WHMCS SEO](https://katamaze.com/blog/37/whmcs-seo-ways-to-improve-your-site-ranking-in-2020) using [WHMCS as CMS](https://katamaze.com/whmcs/mercury).
590 |
591 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/KnowledgebaseLastUpdatedDate.php)
592 |
593 | ## Login as Client Language
594 |
595 | Every time an administrator uses *Login as Client*, WHMCS overrides the default language of the selected customer with the one used by the administrator in WHMCS backend. This is bad because you're unknowingly changing the default language for your customer. This also applies for languages that can't be used in clientarea.
596 |
597 | Let's say your clientarea is in italian and you're using WHMCS backend in english. When you perform the *Login as Client*, WHMCS switches customer's language from italian to english and there's no way back. The customer in question is stucked with a language he cannot change. The following hook prevents that to happen.
598 |
599 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/LoginAsClientPreserveLanguage.php)
600 |
601 | ## Prevent Emails to be sent based on Client Group
602 |
603 | The hook prevents WHMCS from sending *General Messages* email templats to specific client groups based on a sort of blacklist.
604 |
605 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/PreventEmailSendingBasedOnClientGroup.php)
606 |
607 | ## Abort Auto-Provisioning when there's a Note in the Order
608 |
609 | A customer orders a VPS and adds notes to request a particular configuration that requires your manual intervention. In case you're using auto-provisioning, there's no way to stop WHMCS from creating the VPS to let you intervene manually. This hook however can stop auto-provisioning when there's a note in the order.
610 |
611 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/NoteInTheOrderAbortAutoProvisioning.php)
612 |
613 | ## Rename Addon Module Label
614 |
615 | Let's say you don't like how we named [Mercury](https://katamaze.com/whmcs/mercury/specifications), [Commission Manager](https://katamaze.com/whmcs/commission-manager/specifications), [Billing Extension](https://katamaze.com/whmcs/billing-extension/specifications) addon modules and you want to change them to *CMS*, *Affiliates* and *Accounting*. Simply change the following hook accordingly. It works with any WHMCS module.
616 |
617 | 
618 |
619 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/RenameAddonModuleLabel.php)
620 |
621 | ## Add Button next to Module's Functions
622 |
623 | Here is how you can add a button next to *Create*, *Suspend*, *Unsuspend* (...) functions in product/service view.
624 |
625 | 
626 |
627 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/AddButtonNextToModulesFunctions.php)
628 |
629 | ## Announcements Meta Description
630 |
631 | Before you think *«Great! I can finally add meta descriptions to WHMCS announcements»* wait for a sec and understand the following:
632 |
633 | * [WHMCS is terrible at SEO](https://katamaze.com/blog/37/whmcs-seo-ways-to-improve-your-site-ranking-in-2020). You need more than an hook to improve rankings
634 | * [Meta Description](https://katamaze.com/blog/37/whmcs-seo-ways-to-improve-your-site-ranking-in-2020#Meta-description) is **not** a ranking factor. It doesn't affect your rankings but CTR
635 |
636 | You can use the same approach to implement other meta tags but stay away from [meta keywords](https://katamaze.com/blog/37/whmcs-seo-ways-to-improve-your-site-ranking-in-2020#Meta-keywords). It is useless and has been deprecated more than a decade ago by all search engines.
637 |
638 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/AnnuncementsMetaDescription.php)
639 |
640 | ## Prevent Indexing on Search Engines
641 |
642 | With this hook you can stop search engines from indexing your WHMCS site. This is particularly useful for test installations and for sites you still need to launch. The hook adds `noindex` meta tag in the `` of your WHMCS that tells search engine crawlers to not index pages.
643 |
644 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/PreventSearchEngineIndexing.php)
645 |
646 | ## Promotion Code in Email Template
647 |
648 | *Invoice Payment Confirmation* is an Email Template that WHMCS sends to customers when they pay invoices. By default this message doesn't include any information about promotions. The following hook add coupon code to the invoice recepit (if a promo has been applied).
649 |
650 | Once the hook has been added to WHMCS, you can edit *Invoice Payment Confirmation* email template to customize the look of your message like follows.
651 |
652 | ```
653 | {if $assigned_promos}
654 | Promo below:
655 | {foreach from=$assigned_promos item=promo}
656 | {$promo}
657 | {/foreach}
658 | {/if}
659 | ```
660 |
661 | Here is a preview of the message.
662 |
663 | 
664 |
665 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hooks/blob/master/hooks/CouponCodeInEmailTemplate.php)
666 |
667 | ## Promotions array in Email Templates
668 |
669 | This hook is capable of including information about existing promotions (aka coupon codes) in any email notifications sent by WHMCS. It adds `{$promotions}` Smarty array to any of the specified email templates. You only need to iterate records with a Smarty `{foreach}` as follows.
670 |
671 | ```
672 | {if $promotions}
673 | Active Promotions:
674 |
679 | {/if}
680 | ```
681 |
682 | Here's a preview of the following code. Keep in mind that the hook automatically removes expired promotions from the array.
683 |
684 | 
685 |
686 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/PromotionsArrayInEmailTemplates.php)
687 |
688 | ## Automatically Accept Order when Invoice is Paid
689 |
690 | WHMCS requires administrators to manually accept orders even if automation tasks already took place. This hook automatically accepts orders via API when Invoice is paid.
691 |
692 | * Restrict order acceptance based on `$invoiceTotal`. The script automatically performs currency conversion. Leave `false` to auto-accept everything
693 | * Use `<=` as `$operator` to auto-accept orders less than or equal to `$invoiceTotal`. Use `>=` for the opposite
694 |
695 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/AcceptOrderOnInvociePaid.php)
696 |
697 | ## Cancel Order when an Invoice is being Cancelled
698 |
699 | When an invoice is `Mark Cancelled` the related order (if exists) is automatically set `Cancelled`.
700 |
701 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/CancelOrderOnInvoiceCancelled.php)
702 |
703 | ## Ban Order Expiration
704 |
705 | WHMCS administrators can ban IP on the fly directly from order view. The problem with this feature is that WHMCS automatically sets the ban to expire the last day of current year. As you can imagine there's an huge difference between receiving the ban on January instead of December. This hook makes sure that bans always last one full year no matter what.
706 |
707 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/BanOrderExpiration.php)
708 |
709 | ## Hide Google Invisible reCAPTCHA Badge
710 |
711 | All it takes to hide Google Invisible reCAPTCHA Badge (bottom-right corner) is a CSS rule. If you don't want to edit your CSS and/or want preserve the change with template updates, use this hook. Before you ask, yes, the correct way to hide the Badge is to use `opacity`. Using things like `display: none` and `visibility: hidden` breaks reCAPTCHA.
712 |
713 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/HideGoogleInvisibleReCAPTCHA.php)
714 |
715 | ## Chatstack Disable for Logged-In Users and Administrators
716 |
717 | In case you have now idea of what Chatstack is, let me give you a little bit of background. It's an official module of WHMCS that allows to chat with visitors and track their activities. We use it ourselves on [our site](https://katamaze.com/). It's the little badge at the bottom right corner. Visitors can click it to start chatting with us. In case we're not online, the badge redirects to *contact us*.
718 |
719 | It is worth to mention that in past Chatstack was named LiveHelp. You can purchase it directly from [Chatstack](https://www.chatstack.com/) or from WHMCS [Marketplace](https://marketplace.whmcs.com/product/34-live-chat-visitor-tracking). Ignore all the negative reviews. Most of them are from people that have no idea of how to install and configure it 😑
720 |
721 | Let's now move to the hook itself. Once Chatstack is installed on your WHMCS site, it starts tracking everyone including WHMCS administrators and logged-in users. This creates the following problems:
722 |
723 | * You receive notifications about administrators' activities
724 | * Chatstack doesn't distinguish between visitors and administrators
725 | * Chat should be reserved for pre-sales but customers can use it for technical support
726 |
727 | The hook we made provides two options that allows to:
728 |
729 | * Stop tracking and notifying administrators' activities
730 | * Prevent logged-in users (existing customers) to use the chat
731 |
732 | The only requirement is that you remove any existing integration between WHMCS & Chatstack. The action hook handles everything and supports also [WHMCS multi-domain and multi-brand](https://katamaze.com/docs/mercury/48/multi-brand-and-geolocation#Multi-brand-and-multi-domain).
733 |
734 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/ChatstackDisableLoggedInAndAdmin.php)
735 |
736 | ## Notify Fradulent Orders
737 |
738 | When an order is set as fraud, prior to the change of status actually occurring, the hook sends email notifications to all existing WHMCS administrators (disabled administrators are ignored).
739 |
740 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/NotifyFradulentOrders.php)
741 |
742 | ## Conditional Support Departments
743 |
744 | Restrict the access to support departments based on the products purchased by users. Define rules as follows.
745 |
746 | ```
747 | $department['1'] = array('45', '46', '10');
748 | $department['2'] = array('85', '86', '10');
749 | // Keep adding rules one per line
750 | ```
751 |
752 | The key of `$department` array (the `[1]` and `[2]` between square brackets) corresponds to the ID of the support department for which we are creating a rule. The value is an `array()` of product IDs required for access. In a in nutshell, the above configuration unlocks department `#1` to users with product IDs `45`, `46` and `10`. Department `#2` requires `85`, `86` and `10`.
753 |
754 | Here are few more things to consider:
755 |
756 | * `submitticket.php` doesn't show restricted departments
757 | * Access via direct link `submitticket.php?step=2&deptid=2` triggers a redirect to `submitticket.php`
758 | * Department dropdown lists only allowed department
759 | * The same product can be used for multiple rules
760 | * `Pending`, `Suspended`, `Terminated`, `Cancelled` and `Fraud` products are ignored
761 |
762 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Scripts/blob/master/hooks/ConditionalSupportDepartments.php)
763 |
764 | ## Abort Email Sending based on User ID and/or Client Group ID
765 |
766 | Let's take as example the following configuration:
767 |
768 | ```
769 | $disallowedEmailTemplates = array('Invoice Created');
770 | $disallowedClientGroups = array('3');
771 | $disallowedUserIDs = array('1');
772 | $removePDFAttachments = true;
773 | ```
774 |
775 | We are aborting the sending of `Invoice Created` email to client ID `1` and also to clients assigned to client group `3`. You can specify multiple email templates, client groups and user ID - all these parameters are `array()`. The `$removePDFAttachments` can be used to simply remove PDF invoice attachments from emails.
776 |
777 | * `$disallowedEmailTemplates` the system name of the email template that can be found in `Setup > Email Templates`. When you edit a template, the system name appears right below `Email Templates` title
778 | * `$disallowedClientGroups` an array of client group IDs that can be found in `Setup > Client Groups`
779 | * `$disallowedUserIDs` an array of user IDs
780 | * `$removePDFAttachments` set `true` if you simply want to remove PDF invoice attachments for the selected users
781 |
782 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Scripts/blob/master/hooks/AbortEmailSendingBasedOnUserIDClientGroupID.php)
783 |
784 | ## Generate Missing UUID in tblclients
785 |
786 | Importing clients in `tblclients` table via queries or from phpMyAdmin, does not automatically create `uuid` values. This script will generate `uuid` for clients that don't have one yet. It triggers by visiting any page of frontend. Don't forget to remove the it when you finished.
787 |
788 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/GenerateUUID.php)
789 |
790 | ## Change Default Sorting of Tables in Backend
791 |
792 | It feels weird when you open `Billing > Invoices` and WHMCS sorts records by `Due Date`. A more convenient way to sort invoices is by `Invoice Date`. It took me plenty of time to figure out how to change default sorting for tables in backend.
793 |
794 | WHMCS stores sorting order for each page in the mysterious `$_COOKIE['WHMCSSD']` array. Why am I saying mysterious? Because for reasons I can't understand, WHMCS staff decided to `json_encode` and `base64_encode` its content. That's why nobody before me knew this secret.
795 |
796 | [Get the Code »](https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/ChangeDefaultSortingBackendTables.php)
797 |
798 | # Free Reports Collection
799 |
800 | Yay! We didn't stop to action hooks :stuck_out_tongue: Below you can find a list of custom [WHMCS Reports](https://docs.whmcs.com/Reports) to give you more in-depth reporting and analytics on the performance of your business. Let's go!
801 |
802 | ## Churn Rate
803 |
804 | Rate at which customers stop doing business with you. The report includes charts and graphs to help you interpret the data. For every month of the year you can see:
805 |
806 | * No. of products/domains at the start of the month
807 | * No. of products/domains at the end of the month
808 | * Monthly change in the No. of products/domains
809 | * No. of products/domains acquired during the month
810 | * No. of products/domains lost during the month
811 | * Churn rate (percentage)
812 |
813 | The report also shows cumulative statistics (products & domains combined). Churn rate is usually connected to [customer retention](https://katamaze.com/docs/billing-extension/39/client-area#Customer-Retention). The linked article describes how to retain customers. For your information the formula to calculate churn rate is the following.
814 |
815 | ```
816 | (Lost products/domains at the end of Time Period / Acquired products/domains at the end of Time Period) * 100
817 | ```
818 |
819 | The report doesn't take into account products/services with any of the following billing cycles: `One Time`, `Completed`, `Free Account`. The reason for that is very simple. Such products don't support renewals hence churn rate doesn't apply.
820 |
821 | 
822 |
823 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/reports/Churn_Rate.php)
824 |
825 | # Free Modules Collection
826 |
827 | Yep, we also give you some handy modules that can help you with most common operations in WHMCS.
828 |
829 | ## Plesk Checker
830 |
831 | > Error code: 1013. Error message: Customer with external id 'whmcs_plesk_XX' is not found in panel.
832 |
833 | If you're using Plesk I bet you've seen this error at least once in your life. If you try to google it, you'll find a page from [Plesk documentation](https://support.plesk.com/hc/en-us/articles/115002988474-Cannot-login-to-Plesk-via-WHMCS-after-migration-Customer-with-external-id-whmcs-plesk-XX-is-not-found-in-panel) that claims this bug (I quote) *«has been already fixed for all versions»*. I respectfully disagree.
834 |
835 | Probably I'll need a week to explain why this error appears. Let's skip this boring part. Fixing the error requires your manual intervention on `psa` database (Plesk) and more in particular on `clients.external_id` column as described in the article previously linked.
836 |
837 | We created a module that makes this "find and replace" process less frustrating and quicker. Not only it automatically detects all hosting accounts that are returing `Error code: 1013` but also additional ones. Here's a preview.
838 |
839 | 
840 |
841 | [Get the Code »](https://github.com/Katamaze/WHMCS-Free-Action-Hooks/tree/master/modules/addons/PleskChecker)
842 |
843 | # Tweaks
844 |
845 | # Client area Domain List
846 |
847 | According to WHMCS sidebar there are say 8 expired domains but when you apply this filter, the table shows more than 8 records. What is going on? That's simple. WHMCS countings are inconsistent. The sidebar counts expired domains while the table includes in this counting also cancelled domains.
848 |
849 | You can easily solve the problem by editing `clientareadomains.tpl`. Find `{if $domain.expiringSoon}` and replace with `{if $domain.expiringSoon AND $domain.statusClass != 'cancelled'}`.
850 |
--------------------------------------------------------------------------------
/hooks/AbortEmailSendingBasedOnUserIDClientGroupID.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 |
12 | use PHPMailer\PHPMailer\PHPMailer;
13 | use PHPMailer\PHPMailer\Exception;
14 | use WHMCS\Database\Capsule;
15 |
16 | add_hook('EmailPreSend', 1, function($vars)
17 | {
18 | $disallowedEmailTemplates = array('Invoice Created'); // The name of the email template being sent
19 | $disallowedClientGroups = array('3'); // Affected Client Group ID
20 | $disallowedUserIDs = array('5'); // Affected User ID
21 | $removePDFAttachments = true; // Set true if you simply want to remove PDF invoice attachments for the selected users
22 |
23 | switch (Capsule::table('tblemailtemplates')->select('type')->where('name', $vars['messagename'])->first()->type)
24 | {
25 | case 'affiliate': $user = $vars['relid']; break;
26 | case 'domain': $user = Capsule::select(Capsule::raw('SELECT t2.id, t2.groupid FROM tbldomains AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id WHERE t1.id = "' . $vars['relid'] . '" LIMIT 1'))[0]; break;
27 | case 'general': $user = $vars['relid']; break;
28 | case 'invoice': $attachments = true; $user = Capsule::select(Capsule::raw('SELECT t2.id, t2.groupid, t2.language FROM tblinvoices AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id WHERE t1.id = "' . $vars['relid'] . '" LIMIT 1'))[0]; break;
29 | case 'product': $user = Capsule::select(Capsule::raw('SELECT t2.id, t2.groupid FROM tblhosting AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id WHERE t1.id = "' . $vars['relid'] . '" LIMIT 1'))[0]; break;
30 | case 'support': $user = Capsule::select(Capsule::raw('SELECT t2.id, t2.groupid FROM tbltickets AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id WHERE t1.id = "' . $vars['relid'] . '" LIMIT 1'))[0]; break;
31 | default: return; break;
32 | }
33 |
34 | if (in_array($user->groupid, $disallowedClientGroups) OR in_array($user->id, $disallowedUserIDs))
35 | {
36 | $abortSend = true;
37 | }
38 |
39 | if ($removePDFAttachments AND $attachments AND $abortSend)
40 | {
41 | require __DIR__ . '/../../vendor/phpmailer/phpmailer/src/Exception.php';
42 | require __DIR__ . '/../../vendor/phpmailer/phpmailer/src/PHPMailer.php';
43 | require __DIR__ . '/../../vendor/phpmailer/phpmailer/src/SMTP.php';
44 |
45 | foreach (Capsule::select(Capsule::raw('SELECT setting, value FROM tblconfiguration WHERE setting IN ("CompanyName", "Email", "MailType", "SMTPHost", "SMTPUsername", "SMTPPassword", "SMTPPort", "SMTPSSL")')) as $v)
46 | {
47 | if ($v->setting == 'SMTPPassword' AND $v->value): $v->value = Decrypt($v->value); endif;
48 | $conf[$v->setting] = $v->value;
49 | }
50 |
51 | $mail = new PHPMailer;
52 | $mail->CharSet = 'UTF-8';
53 |
54 | try
55 | {
56 | if ($conf->MailType == 'smtp')
57 | {
58 | $mail->IsSMTP();
59 | $mail->Host = $conf['SMTPHost'];
60 | $mail->SMTPAuth = true;
61 | $mail->SMTPSecure = $conf['SMTPSSL'];
62 | $mail->Port = $conf['SMTPPort'];
63 | $mail->Username = $conf['SMTPUsername'];
64 | $mail->Password = $conf['SMTPPassword'];
65 | $mail->Mailer = 'smtp';
66 | $mail->CharSet = 'UTF-8';
67 | }
68 | else
69 | {
70 | $mail->IsMail();
71 | $mail->CharSet = 'UTF-8';
72 | }
73 |
74 | $emailTemplate = Capsule::select(Capsule::raw('SELECT subject, message FROM tblemailtemplates WHERE name = "' . $vars['messagename'] . '" AND language = "' . $user->language . '" LIMIT 1'))[0];
75 |
76 | foreach (array('invoice_html_contents', 'client_name', 'invoice_date_created', 'invoice_payment_method', 'invoice_num', 'invoice_total', 'invoice_date_due', 'signature') as $v)
77 | {
78 | $emailTemplate->subject = str_replace('{$' . $v . '}', $vars['mergefields'][$v], $emailTemplate->subject);
79 | $emailTemplate->message = str_replace('{$' . $v . '}', $vars['mergefields'][$v], $emailTemplate->message);
80 | }
81 |
82 | $mail->AddAddress($vars['mergefields']['client_email'], $vars['mergefields']['client_name']);
83 | $mail->SetFrom($conf['Email'], $conf['CompanyName']);
84 | $mail->Subject = $emailTemplate->subject;
85 | $mail->MsgHTML($emailTemplate->message);
86 | $mail->Send();
87 | $mail->ClearAllRecipients();
88 | }
89 | catch (phpmailerException $e)
90 | {
91 | //echo $e->errorMessage(); // Pretty error
92 | }
93 | catch (Exception $e)
94 | {
95 | //echo $e->getMessage(); // Boring error
96 | }
97 | }
98 |
99 | if ($abortSend)
100 | {
101 | return array('abortsend' => true);
102 | }
103 | });
104 |
--------------------------------------------------------------------------------
/hooks/AcceptOrderOnInvociePaid.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 |
12 | use WHMCS\Database\Capsule;
13 |
14 | add_hook('InvoicePaid', 1, function($vars) {
15 |
16 | $orderID = Capsule::table('tblorders')->where('invoiceid', '=', $vars['invoiceid'])->pluck('id')[0];
17 | if (!$orderID): return; endif;
18 |
19 | $invoiceTotal = '10'; // Auto-accept order based on invoice total. The script automatically performs currency conversion. Leave false to auto-accept everything
20 | $operator = '<='; // Use "<=" to auto-accept orders less than or equal to $invoiceTotal. Use ">=" for the opposite
21 |
22 | if ($invoiceTotal) {
23 |
24 | $currency = Capsule::select(Capsule::raw('SELECT t3.rate FROM tblinvoices AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id LEFT JOIN tblcurrencies AS t3 ON t2.currency = t3.id WHERE t1.id = "' . $vars['invoiceid'] . '" AND t3.default = "0" LIMIT 1'))[0];
25 | $invoiceTotal = ($currency ? $invoiceTotal * $currency->rate : $invoiceTotal);
26 |
27 | if (Capsule::select(Capsule::raw('SELECT id FROM tblinvoices WHERE id = "' . $vars['invoiceid'] . '" AND (total ' . ($operator == '>=' ? '<=' : '>=') . ' "' . $invoiceTotal . '" OR credit ' . ($operator == '>=' ? '<=' : '>=') . ' "' . $invoiceTotal . '") LIMIT 1'))[0]) {
28 |
29 | return;
30 | }
31 | }
32 |
33 | $adminUsername = ''; // Optional for WHMCS 7.2 and later
34 | localAPI('AcceptOrder', array('orderid' => $orderID), $adminUsername);
35 | });
36 |
37 | add_hook('AfterProductUpgrade', 1, function($vars) {
38 |
39 | $orderID = Capsule::table('tblupgrades')->where('id', '=', $vars['upgradeid'])->pluck('orderid')[0];
40 | if (!$orderID): return; endif;
41 |
42 | $invoiceTotal = '10'; // Auto-accept order based on invoice total. The script automatically performs currency conversion. Leave false to auto-accept everything
43 | $operator = '<='; // Use "<=" to auto-accept orders less than or equal to $invoiceTotal. Use ">=" for the opposite
44 |
45 | if ($invoiceTotal) {
46 |
47 | $currency = Capsule::select(Capsule::raw('SELECT t3.rate FROM tblinvoices AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id LEFT JOIN tblcurrencies AS t3 ON t2.currency = t3.id WHERE t1.id = "' . $vars['invoiceid'] . '" AND t3.default = "0" LIMIT 1'))[0];
48 | $invoiceTotal = ($currency ? $invoiceTotal * $currency->rate : $invoiceTotal);
49 |
50 | if (Capsule::select(Capsule::raw('SELECT t2.id FROM tblorders AS t1 LEFT JOIN tblinvoices AS t2 ON t1.invoiceid = t2.id WHERE t1.id = "' . $orderID . '" AND (t2.total ' . ($operator == '>=' ? '<=' : '>=') . ' "' . $invoiceTotal . '" OR t2.credit ' . ($operator == '>=' ? '<=' : '>=') . ' "' . $invoiceTotal . '") LIMIT 1'))[0]) {
51 |
52 | return;
53 | }
54 | }
55 |
56 | $adminUsername = ''; // Optional for WHMCS 7.2 and later
57 | localAPI('AcceptOrder', array('orderid' => $orderID), $adminUsername);
58 | });
59 |
--------------------------------------------------------------------------------
/hooks/AcceptQuoteWithoutLogin.php:
--------------------------------------------------------------------------------
1 |
10 | *
11 | */
12 |
13 | use WHMCS\Database\Capsule;
14 |
15 | add_hook('EmailPreSend', 1, function($vars)
16 | {
17 | if (in_array($vars['messagename'], array('Quote Delivery with PDF')))
18 | {
19 | if ($vars['mergefields']['quote_link'])
20 | {
21 | $data = Capsule::select(Capsule::raw('SELECT t1.id, t2.id AS clientid, t2.email FROM tblquotes AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id WHERE t1.id = "' . $vars['mergefields']['quote_number'] . '" LIMIT 1'))[0];
22 |
23 | $hash = strrev(md5($data->id . $data->clientid . $data->email)) . '-' . $data->id;
24 | $quote_link = (new SimpleXMLElement($vars['mergefields']['quote_link']))['href'];
25 | $url = parse_url($quote_link);
26 | $merge_fields['quote_link'] = str_replace($quote_link, $url['scheme'] . '://' . $url['host'] . '/index.php?qhash=' . $hash, $vars['mergefields']['quote_link']);
27 |
28 | return $merge_fields;
29 | }
30 | }
31 | });
32 |
33 | add_hook('ClientAreaHeadOutput', 1, function($vars)
34 | {
35 | if ($_GET['qhash'])
36 | {
37 | $data = Capsule::select(Capsule::raw('SELECT t1.id, t1.subject, t2.id AS clientid, t2.firstname, t2.email FROM tblquotes AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id WHERE t1.id = "' . explode('-', $_GET['qhash'])[1] . '" AND stage != "Accepted" LIMIT 1'))[0];
38 | $hash = strrev(md5($data->id . $data->clientid . $data->email)) . '-' . $data->id;
39 |
40 | if ($hash === $_GET['qhash'])
41 | {
42 | $adminUsername = ''; // Optional for WHMCS 7.2 and later
43 | $results = localAPI('AcceptQuote', array('quoteid' => $data->id), $adminUsername);
44 | $results = localAPI('SendEmail', array('messagename' => 'Invoice Created', 'id' => $results['invoiceid']), $adminUsername);
45 |
46 | return <<
48 | setTimeout(function()
49 | {
50 | $("#modalAjax .modal-title").html('Quote #{$data->id} Accepted');
51 | $("#modalAjax .modal-body").html('
Hey, {$data->firstname}
Thanks for accepting quote #{$data->id} ({$data->subject}). Here is what happens now:
You will receive the invoice shortly
Once we receive your payment, we\'ll activate your order
Please do not hesitate to contact us if you have any questions.