Skip to content

Free collection of Action Hooks, Reports and Modules to perfect your WHMCS

License

Notifications You must be signed in to change notification settings

Katamaze/WHMCS-Action-Hook-Factory

Repository files navigation

Table of Contents

⚠️ Disclaimer: I'm Done with WHMCS ⚠️

This page has helped a lot of people but I'm done with this software. WHMCS no longer deserves my time and skills. I wrote a post to explain why after 15 years I am leaving WHMCS and why you should do the same thing.

TL;DR version. Leave WHMCS because:

  • Is a clusterfuck of bugs where the biggest one is WHMCS staff itself
  • WHMCS leaders DNA? Greediness, disrespect, lies and unprofessionalism
  • 3154% price increase during the coronavirus pandemic
  • Passive-aggressive communication 24/7 is all you can expect
  • Software designed to milk customers like cattle

WHMCS as Fast as Possible

It's much easier to understand what is WHMCS making a parallelism with WordPress. Of the many free CMS, WordPress is the best and most popular solution to start a blog. WHMCS is the same in its reference market. It's the way go to start an hosting business for providers, web agencies and IT professionals.

Both systems are the undisputed market leaders in their respective field. WordPress reaches 60% of market share. WHMCS attracts about 50.000 customers worldwide. They are both flexible and can accommodate several businesses needs. In them there's more than a control panel and a blogging platform.

That said, similarities end here. WordPress is free, open source and good at many things. WHMCS kicks off at 15.95 $ per month. Source code is obfuscated and even if it is a solid platform, WHMCS is not perfect.

Continue reading our beginners guide to WHMCS and common mistakes to avoid in WHMCS for more details.

Understanding Action Hooks

Action Hooks allow you to execute your own code when events occur inside WHMCS. With them you can achieve impressive results.

For example we managed to transform WHMCS into a CMS like WordPress with full support for Search Engine Optimization. We've also introduced new billing concepts (monthly invoicing, electronic invoicing, credit notes) and Affiliate Marketing.

As you can see you can there's no limit to imagination. If you're new to WHMCS and Action Hooks, please refer to documentation:

Perfect Your WHMCS

Over the years we coded thousand of action hooks most of which are part of our WHMCS modules.

In this repository we share a collection of action hooks for free that you can copy/paste on your WHMCS site. You can also adapt them to your specific needs or use as inspiration for your projects.

The point of this this project is to help Developers, Hosting Providers, Web Agencies and IT professionals to perfect WHMCS. We are continually adding and improving hooks. It would be great if you could join us!

Free Hooks Collection

This blog post contains in-depth instructions and previews. It is also available in italian language. We are always willing to code new hooks based on your feedback so feel free to comment and ask for new ones.

Scripts are provided free of charge "as is" without warranty of any kind. You're not allowed to remove copyright notice. Let's start!

Update Existing URLs to Admin when Custom Admin Path Changes

Let's say you need to change your Custom Admin Path from https://katamaze.com/admin to https://katamaze.com/new_admin. Renaming the WHMCS admin diretcory is a straightforward process that however doesn't automatically search old links and replace them with new ones.

Ticket notes, admin notes and to-do lists keep hundreds if not thousands of internal URLs still pointing to old paths like in the following example.

whmcs-auto-update-old-url-with-new-admin-path

This action hook detects when you change Custom Admin Path via configuration.php and automatically find and replace old path with current one in all URLs. That's how https://katamaze.com/admin/invoices.php?action=edit&id=589 becomes https://katamaze.com/admin_new/invoices.php?action=edit&id=589. The action is performed on:

  • Admin notes (tbladmins.notes)
  • Notes (tblnotes.note)
  • Ticket Notes (tblticketnotes.message)
  • To-do entries (tbltodolist.description)
  • Project Management Tasks (mod_projecttasks.task, mod_projecttasks.notes) - Optional
  • Project Management Messages (mod_projectmessages.message) - Optional

Get the Code »

Remove IP Address from View Ticket page in Client Area

WHMCS automatically inserts visitor/customer IP address in every submitted reply. If you don't like it you can remove this section via action hook. There's no other way since in modern versions of WHMCS this parameter is hardcoded and can't be changed from template file.

Get the Code »

Conditional Client Custom Fields based on selected country

Hide/show Client Custom Fields based on the currently selected country as shown in the following animated gif.

Get the Code »

Prevent Admins from accessing WHMCS backend during Maintenance

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.

Get the Code »

If client's group this than that

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.

I got inspiration from 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:

  • Enable/disable tax exempt status
  • Replace Pay to text of invoices with anything you want
  • Define an array of allowed payment methods. This implies that other payment methods are restriced

In the example you find in the script, I prepared the following scenario:

  • Clients belonging to group id 1:
    • Tax exempt: Enabled
    • Default Invoice header (Pay To) replaced with Ferrari S.p.A. ...
    • 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
  • Clients belonging to group id 2:
    • Tax exempt: Disabled
    • Default Invoice header (Pay To) replaced with Juventus S.p.A. ...
    • Allowed payment methods: banktransfer (default). Same principle previously described. Other gateways get restricted from open invoices and dropdown

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.

Get the Code »

Restrict payment gateways based on client group

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.

Get the Code »

Admin Stats for WHMCS v8

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.

image

image

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.

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.

Get the Code »

Client Group Color in Ticket View for WHMCS v8

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.

image

Get the Code »

Simulate / Run WHMCS Daily Cron Job on Demand

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.

image

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 to let visitors try our modules before purchase.

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.

image

Get the Code »

Accept Quote without Logging In

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.

When the visitor clicks the link, the quote is automatically accepted and he/she sees the following modal on screen.

image

Get the Code »

Bulk Auto Recalculate Client Domain & Products/Services

Yes, WHMCS integrates Bulk Pricing Updater 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.

image

Second it shows this modal on screen where you can freely choose to auto-recalculate domains or products/services.

image

Get the Code »

No Dates in Invoice Items Description

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:

  • DD/MM/YYYY
  • DD.MM.YYYY
  • DD-MM-YYYY
  • MM/DD/YYYY
  • YYYY/MM/DD
  • YYYY-MM-DD

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).

Get the Code »

cPanel & Plesk login button in My Services

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.

image

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.

Open templates/{YOUR_TEMPLATE}/clientareaproducts.tpl and add the new Manage column in thead like follows.

<thead>
    <tr>
        <th>{$LANG.orderproduct}</th>
        <th>{$LANG.clientareaaddonpricing}</th>
        <th>{$LANG.clientareahostingnextduedate}</th>
        <th>{$LANG.clientareastatus}</th>
        <th>{$LANG.manage}</th>
        <th class="responsive-edit-button" style="display: none;"></th>
    </tr>
</thead>

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.

<td class="text-center">
	{if $kt_autologin[$service.id]}
	<div class="btn-group btn-group-sm plesk-login" style="width:60px;">
		<a href="clientarea.php?action=productdetails&id={$service.id}&autologin=1" target="_blank" class="btn btn-primary btn-xs" alt="Click to Login" title="Click to Login" style="padding: 2px 5px;"><img src="templates/{$template}/img/katamaze_autologin/{$kt_autologin[$service.id]->type}.png" style="height:22px; max-width:39px"> <i class="fa fa-sign-in fa-fw" aria-hidden="true"></i></a>
	</div>
	{/if}
</td>

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.

{include file="$template/includes/tablelist.tpl" tableName="ServicesList" noSortColumns="4" filterColumn="3"}

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".

Get the Code »

Related Service in Ticket Sidebar

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).

image

Get the Code »

Force Payment Gateway depending on Invoice Balance

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 helps you saving up to 18% on transaction fees but such costs can be lowered even further.

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.

  • PayPal charges 3.4% + 0.35 € per transaction meaning that receiving 1000 € costs you 35.35 €
  • Let's suppose on a yearly basis you receive 10 payments of 1000 €
  • At the end of the year you gave to PayPal 353.5 €

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.

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.

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:

# Notes
$notes = str_replace('Payment Method Unlocked by Administratror', '', $notes);
$notes = ($notes ? $notes : false);
if ($notes) {
    $pdf->Ln(5);
    $pdf->SetFont($pdfFont, '', 8);
    $pdf->MultiCell(170, 5, Lang::trans('invoicesnotes') . ': ' . $notes);
}

Get the Code »

Auto-Terminate Free Trials After X Minutes

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.

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:

  • $productIDs array of Product ID you want to terminate or suspend
  • $terminateAfter terminate or suspend products after the given number of minutes (1440 = full day - 0 to disable) integer
  • $performAction can choose between Terminate and Suspend

Get the Code »

Stronger Password Generator for Auto-Provisioning

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.

  • v1 randomly picks 10 characters from a-zA-Z0-9 and !@#$%^&*()-=+?
  • v2 same as above but makes sure that at least one special character is included in the password
  • v3 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

One-off Products/Services & Domain purchase requires Product/Service

If you have a bit of experience with WHMCS, you know that offering promotions just via coupon codes isn't so flexible.

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:

  • kt_onetimeProducts array of product IDs to treat as "one-off" (customer is not allowed to order the same product multiple times)
  • kt_onetimeProductGroups same as above but for product group IDs. Producs inside such groups are treated as one-off
  • kt_firstTimerTollerance product-based restrictions are disabled for new customers placing their first order with you
  • kt_notRepeatable if a customer already has a one-off product, he can't purchase further one-offs (kt_firstTimerTollerance is ignored)
  • kt_domainRequiresProduct domain purchase is allowed only if any of the following conditions is met:
    • Customer has an existing product/service (Pending and Terminated don't count)
    • Customer is purchasing a domain and a product/service
  • 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
  • kt_promptRemoval notify customer about restrictions via (previews are below):
    • bootstrap-alert right below Review & Checkout
    • modal on screen
    • js-alert on scren
  • kt_textDisallowed message displayed for product-based restriction
  • kt_textRequireProduct message displayed for domain-based resrticion

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.

image

The script highlights products/services used for promotions in green and with "promo" label.

image

Get the Code »

New Clients as Affiliates

Automatically sets newly registered customers as Affiliates on WHMCS. This way they don't need to join manually.

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.

Get the Code »

Send Email & Add Reply on Ticket Status Change

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.

Get the Code »

Ticket Feedback on Auto Close via Escalation Rule

Sending 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:

  • When the ticket is closed by an admin user
  • For inactivity Setup > Automation Settings > Support Ticket Settings > Close Inactive Tickets
  • Via escalation rules

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:

  • $cronFrequency must be equal to your System Cron Frequency
  • You must use unique names for escalation rules

Get the Code »

Disable Feedback for Unanswered Tickets

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.

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.

Get the Code »

Client to Group based on Purchased Items

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.

$groups['products']['1'] = array('1', '2', '3');
$groups['products']['2'] = array('4');
$groups['productaddons']['1'] = array('2');
$groups['configurableoption']['3'] = array('5' => true, '6' => array('7', '8', '10'));

The key of the first level of $groups array (eg. ['products']) can assume the following values:

  • products for group/product pairs
  • productaddons for group/product addon pairs
  • configurableoption for group/configurable option paris

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:

  • Customer A purchases product 1. He goes to client group ID 1
  • Customer B purchases product 2. He still goes to client group ID 1
  • Customer C purchases product 4. He goes to client group ID 2
  • Customer D purchases product 5. No action taken
  • Customer E purchases product 1 and is already assigned to a client group. No action taken
  • Customer F purchases product addon 2. He goes to client group ID 1
  • Customer G purchases a product selecting any value of configurable option ID 5. He goes to client group ID 3
  • Customer H purchases a product selecting specifically 7, 8 or 10 options of configurable option ID 6. He goes to client group ID 3

The script is available in two versions. The configuration is the same. What changes is the hook point:

  • AcceptOrder version assigns the group when the order is accepted - both manually and automatically
  • EmailPreSend version 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

Client to Group based on Registration Date

This hook is similar to the one that assigns clients to groups based on purchases. 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.

$groups['1'] = '90';
$groups['2'] = '180';
$groups['3'] = '365';

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:

  • Customer A registered 34 days ago. No change
  • Customer B registered 90 days ago. He goes to client group ID 2
  • Customer C registered 364 days ago. Still group ID 2
  • Customer D registered 500 days ago. He goes to client group ID 3

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:

  • $activeCustomers rules apply only on Active customers (boolean true or false)
  • $oldestPurchase rules apply only on if customer has a product/service or domain older than the given number of days (integear)
  • $ignoreDomains set true to ignore domain purchases when $oldestPurchase is in use
  • $ignoreProducts array of product IDs to ignore when $oldestPurchase is in use

Get the Code »

Client to Group based on Registered Domains

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. Let's take this code as example.

$groups['1'] = '10';
$groups['2'] = '25';
$groups['3'] = '100';

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:

  • 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
  • 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
  • Customer C has 250 domains. Group ID 3

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:

  • $activeCustomers rules apply only on Active customers (boolean true or false)
  • $placeholderGroup used to restrict assignments to a specific group (group ID or false to disable). This option requires further explanation as detailed below

Let's assume we use the following configuration.

$groups['1'] = '10';
$groups['2'] = '25';
$groups['3'] = '100';

$placeholderGroup = '5';

The hook processes assignments only on clients assigned to group ID 5 (the placeholder), 1, 2 and 3. Let's see some examples:

  • Customer A has 250 domains and is assigned to group 5. After cron job he's moved to group 3
  • 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

The placeholder can also be one of the existing group as in the following example:

$groups['1'] = '10';
$groups['2'] = '25';
$groups['3'] = '100';

$placeholderGroup = '1';

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.

image

Get the Code »

Exempt Existing Clients from Affiliate Commissions

If a visitor places an order for a product or service with the affiliation cookie 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.

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.

Get the Code »

Prevent changes to Client Custom Fields

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.

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.

If you need something more professional, Billing Extension can bring your WHMCS to the next level with things like monthly invoicing, electronic invoicing, customer retention, Facebook Pixel and much more.

Get the Code »

Quote to Invoice conversion without redirect

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.

Get the Code »

Remove/Hide Breadcrumb

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.

Bonus tip: if you don't want to use an action hook, you can use the following CSS. The result is the same.

.breadcrumb li:first-child {
    display:none;
}
.breadcrumb li:nth-child(2):before {
    content:" ";
}

Get the Code »

Knowledgebase Author

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.

image

Get the Code »

Knowledgebase Last Updated Date

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.

If you're looking for something more professional and up to date, learn how to benefit from WHMCS SEO using WHMCS as CMS.

Get the Code »

Login as Client Language

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.

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.

Get the Code »

Prevent Emails to be sent based on Client Group

The hook prevents WHMCS from sending General Messages email templats to specific client groups based on a sort of blacklist.

Get the Code »

Abort Auto-Provisioning when there's a Note in the Order

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.

Get the Code »

Rename Addon Module Label

Let's say you don't like how we named Mercury, Commission Manager, Billing Extension 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.

image

Get the Code »

Add Button next to Module's Functions

Here is how you can add a button next to Create, Suspend, Unsuspend (...) functions in product/service view.

image

Get the Code »

Announcements Meta Description

Before you think «Great! I can finally add meta descriptions to WHMCS announcements» wait for a sec and understand the following:

You can use the same approach to implement other meta tags but stay away from meta keywords. It is useless and has been deprecated more than a decade ago by all search engines.

Get the Code »

Prevent Indexing on Search Engines

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 <head> of your WHMCS that tells search engine crawlers to not index pages.

Get the Code »

Promotion Code in Email Template

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).

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.

{if $assigned_promos}
Promo below:
{foreach from=$assigned_promos item=promo}
{$promo}
{/foreach}
{/if}

Here is a preview of the message.

image

Get the Code »

Promotions array in Email Templates

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.

{if $promotions}
Active Promotions:
<ul>
	{foreach from=$promotions item=promo}
	<li>{$promo.code} ({if $promo.type == 'Percentage'}{$promo.value}% discount{elseif $promo.type == 'Fixed Amount'}{$promo.value} € discount{elseif $promo.type == 'Price Override'}Price override {$promo.value} €{elseif $promo.type == 'Free Setup'}Free Seutp{/if})</li>
	{/foreach}
</ul>
{/if}

Here's a preview of the following code. Keep in mind that the hook automatically removes expired promotions from the array.

image

Get the Code »

Automatically Accept Order when Invoice is Paid

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.

  • Restrict order acceptance based on $invoiceTotal. The script automatically performs currency conversion. Leave false to auto-accept everything
  • Use <= as $operator to auto-accept orders less than or equal to $invoiceTotal. Use >= for the opposite

Get the Code »

Cancel Order when an Invoice is being Cancelled

When an invoice is Mark Cancelled the related order (if exists) is automatically set Cancelled.

Get the Code »

Ban Order Expiration

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.

Get the Code »

Hide Google Invisible reCAPTCHA Badge

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.

Get the Code »

Chatstack Disable for Logged-In Users and Administrators

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. 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.

It is worth to mention that in past Chatstack was named LiveHelp. You can purchase it directly from Chatstack or from WHMCS Marketplace. Ignore all the negative reviews. Most of them are from people that have no idea of how to install and configure it 😑

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:

  • You receive notifications about administrators' activities
  • Chatstack doesn't distinguish between visitors and administrators
  • Chat should be reserved for pre-sales but customers can use it for technical support

The hook we made provides two options that allows to:

  • Stop tracking and notifying administrators' activities
  • Prevent logged-in users (existing customers) to use the chat

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.

Get the Code »

Notify Fradulent Orders

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).

Get the Code »

Conditional Support Departments

Restrict the access to support departments based on the products purchased by users. Define rules as follows.

$department['1'] = array('45', '46', '10');
$department['2'] = array('85', '86', '10');
// Keep adding rules one per line

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.

Here are few more things to consider:

  • submitticket.php doesn't show restricted departments
  • Access via direct link submitticket.php?step=2&deptid=2 triggers a redirect to submitticket.php
  • Department dropdown lists only allowed department
  • The same product can be used for multiple rules
  • Pending, Suspended, Terminated, Cancelled and Fraud products are ignored

Get the Code »

Abort Email Sending based on User ID and/or Client Group ID

Let's take as example the following configuration:

$disallowedEmailTemplates = array('Invoice Created');
$disallowedClientGroups = array('3');
$disallowedUserIDs = array('1');
$removePDFAttachments = true;

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.

  • $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
  • $disallowedClientGroups an array of client group IDs that can be found in Setup > Client Groups
  • $disallowedUserIDs an array of user IDs
  • $removePDFAttachments set true if you simply want to remove PDF invoice attachments for the selected users

Get the Code »

Generate Missing UUID in tblclients

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.

Get the Code »

Change Default Sorting of Tables in Backend

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.

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.

Get the Code »

Free Reports Collection

Yay! We didn't stop to action hooks 😛 Below you can find a list of custom WHMCS Reports to give you more in-depth reporting and analytics on the performance of your business. Let's go!

Churn Rate

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:

  • No. of products/domains at the start of the month
  • No. of products/domains at the end of the month
  • Monthly change in the No. of products/domains
  • No. of products/domains acquired during the month
  • No. of products/domains lost during the month
  • Churn rate (percentage)

The report also shows cumulative statistics (products & domains combined). Churn rate is usually connected to customer retention. The linked article describes how to retain customers. For your information the formula to calculate churn rate is the following.

(Lost products/domains at the end of Time Period / Acquired products/domains at the end of Time Period) * 100

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.

image

Get the Code »

Free Modules Collection

Yep, we also give you some handy modules that can help you with most common operations in WHMCS.

Plesk Checker

Error code: 1013. Error message: Customer with external id 'whmcs_plesk_XX' is not found in panel.

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 that claims this bug (I quote) «has been already fixed for all versions». I respectfully disagree.

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.

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.

image

Get the Code »

Tweaks

Client area Domain List

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.

You can easily solve the problem by editing clientareadomains.tpl. Find {if $domain.expiringSoon} and replace with {if $domain.expiringSoon AND $domain.statusClass != 'cancelled'}.