SlideShare a Scribd company logo
WHMCS | Addon Module Documentation 1
WHMCS Addon Module Docs
Last Updated: 7th December 2010
WHMCS | Addon Module Documentation 2
Contents
3. Introduction
4. Getting Started
5. Configuration
6. Activating/Deactivating
7. Content/Output
8. Sidebar
9. Multi-Language
10. Hooks
11. Upgrades
12. Useful Resources
WHMCS | Addon Module Documentation 3
Introduction
Addon modules allow you to create both admin pages and hooks to extend WHMCS further.
Modules can consist of just an admin page, or just hooks, or both. And they are all managed
through the Setup > Addon Modules interface.
Once activated, the modules will display in a dedicated “Addons” dropdown menu within
the admin area for quick & easy access from any page.
Management options consist of activating and deactivating of the modules, aswell as access
control which allows full admins to define exactly which of the administrator roles are
allowed to access each addon module.
Why would I use a module for a hook?
You might be asking why would I create an admin module when I could just create a hook?
And the answer to that would be that creating a module provides an easy way for users to
install and remove the addon through the dedicated addon modules
WHMCS | Addon Module Documentation 4
Getting Started
To get started, you need to begin by choosing a name for your module. This name should be
unique among all the modules in WHMCS, and should contain only letters & numbers, all
lowercase. Underscores are on the only special characters that are accepted. For example,
valid names would be:
mymodulename
my_module_name
my_module_v5
Once you have chosen your name, you need to create a directory and module file for it. The
directory should be in the format /modules/addons/your_module_name/ and then the key
module file within it should be named “your_module_name.php”.
We have created an example module file which you can use as a basis for all your custom
modules to help with getting started, and that can be found at the path
/modules/addons/addonexample/ within your WHMCS installation.
Now let’s move onto customising the module…
WHMCS | Addon Module Documentation 5
Configuration
The first step in the module is defining the configuration data. This includes the module
name, version number, author, description and any configuration fields that might be
needed. Below is an example of the config function function:
function your_module_name_config() {
$configarray = array(
'name' => 'Friendly Display Name Here',
'version' => '1.0',
'author' => 'Your Name Here',
'description' => 'Description of your Addon/Module Here',
'fields' => array(
'username' => array("FriendlyName" => "API Username", "Type" => "text", "Size" =>
"30", ),
'password' => array("FriendlyName" => "API Password", "Type" => "password", "Size"
=> "30", ),
'signature' => array("FriendlyName" => "API Signature", "Type" => "password", "Size"
=> "50", “Description” => “You will find this in your account settings“, ),
),
);
return $configarray;
}
The first 4 fields: name, version, author & description should all be fairly self-explanatory.
These just need to contain the name you want displaying within the admin area for your
module, version number, your name/company and a brief description of the addon.
The fields section is where you can define the input you need from end users to be able to
make the module work. In this example we are asking for some API related information.
Supported field types are “text”, “password”, “yesno” (checkboxes), “textarea” and
“dropdown”. If using the textarea option then you can add a “Rows” parameter to define
the height of the box, and if using the dropdown type, then you must specify an “Options”
parameter with a comma separated list of values.
There is an optional language variable you can also include if you will be using language files
for your module - we’ll look at those in more detail later on.
WHMCS | Addon Module Documentation 6
Activating/Deactivating
Modules can contain both activate and deactivate functions which run when an admin user
activates or deactivates the module in the Addon Modules configuration area.
These functions can be used to create custom tables, database entries, perform license
checks, or anything else you need to run at the time of initial activation or final deactivation.
The deactivation function should undo everything that the activation function does in order
to fully remove the module from the users system.
One point to note is that there will already be an active database connection when the
module is run, so to access the WHMCS database you won’t need to reconnect to the
database.
So for example, the activate and deactivate functions could create and drop a table for use
by the custom module as below:
function your_module_name_activate() {
$query = "CREATE TABLE `mod_customtable` (`id` INT( 1 ) NOT NULL AUTO_INCREMENT
PRIMARY KEY ,`key` VARCHAR( 16 ) NOT NULL ,`value` TEXT NOT NULL )";
mysql_query($query);
}
function your_module_name_deactivate() {
$query = "DROP TABLE `mod_customtable`";
mysql_query($query);
}
WHMCS | Addon Module Documentation 7
Content/Output
Output from the modules needs to be defined in the function your_module_name_output
and should be actually output, (ie. echo’d) not returned.
All output will then be captured by WHMCS and displayed within the admin interface
template. The module name is automatically prefixed to the output.
Variables
The output function is passed all of the fields defined in your modules config, along with the
values users have set for them, aswell as a “modulelink” variable which you can use to link
back to the module.
Linking/Actions
Using the modulelink variable passed into the output function, you can then create links and
forms that post back to your module. The modulelink will be in the format
“addonmodules.php?module=xxxxxx” so for links you can then append “&var1=x&var2=y”
or with forms you can use the POST form method to receive user input.
Within the output function you can then check the $_GET or $_POST variables received in
the request in order to display other output or perform various tasks once links have been
followed.
Admin User Data
You can access the currently logged in admin ID should you need that within your module
using $_SESSION[‘adminid’] and from that can lookup any additional information you need
in tbladmins.
Example
function your_module_name_output($vars) {
$modulelink = $vars['modulelink'];
$username = $vars['username'];
$password = $vars['password'];
echo '<p>Your username is '.$username.'</p>';
}
WHMCS | Addon Module Documentation 8
Sidebar
An addon module can also define HTML code to be displayed in the sidebar. You can do
anything you want with this, but it is ideal for creating custom sub menus specific to a
custom module.
The function is passed all the same variables as the main content output function, and so
can be used like this:
function your_module_name_sidebar($vars) {
$modulelink = $vars['modulelink'];
$username = $vars['username'];
$password = $vars['password'];
$sidebar = '<span class="header"><img src="images/icons/addonmodules.png"
class="absmiddle" width="16" height="16" /> Sample</span>
<ul class="menu">
<li><a href="#">Sample Sidebar Link 1</a></li>
<li><a href="#">Sample Sidebar Link 2</a></li>
</ul>';
return $sidebar;
}
WHMCS | Addon Module Documentation 9
Multi-Language
Modules can be designed to support multiple languages should you wish.
For this, the addon module simply needs a lang subfolder creating within it, and within that
language files can be created matching the names of the main WHMCS admin area language
files located in the /admin/lang/ folder.
The language variables for custom modules are kept separate in language files within the
module’s own folder to make installation and updating easier.
If language files exist, WHMCS will then automatically load these whenever the custom
module is accessed, automatically selecting the appropriate language file based on the
currently logged in administrators language profile setting. If no matching language file
exists within the custom module’s folder for the language the admin is using then it will
simply fall back to the default language you set in the module’s config array.
The language variables are then passed into both the _output and _sidebar functions
variables array using “_lang”.
Please refer to the example addon modules language file located in
/modules/addons/addonexample/lang/english.php for the format to use for your custom
language variables.
Below is a demonstration of how you specify the default language for your module in the
config array.
function your_module_name_config() {
$configarray = array(
'name' => 'Friendly Display Name Here',
'version' => '1.0',
'author' => 'Your Name Here',
'description' => 'Description of your Addon/Module Here',
'language' => 'english',
'fields' => array(
etc…
WHMCS | Addon Module Documentation 10
Hooks
To create hooks that your module should define within WHMCS, you simply need to create
a file named “hooks.php” within your custom module folder, and that will then be
automatically detected and any hooks loaded on every page of WHMCS.
The hook functions within that file should be defined in exactly the same way as normal.
Please refer to http://wiki.whmcs.com/Hooks for more information on creating hooks.
WHMCS | Addon Module Documentation 11
Upgrades
Releasing updates and upgrades to your custom modules is likely something you will want
to do at some point in time. And if those require modifying the database structure or
performing other functions that would otherwise be performed in the _activate function
when being activated for the first time, then you need some way of handling that.
With the Addon Modules system, this is a breeze with the upgrade function. The upgrade
function is called the first time a module is accessed following an update. The update is
detected by a change of version number in the _config array of the module, and so if a
change is detected, the _upgrade function will be called. The upgrade function is passed the
previous version number so that you can then decide what updates you need to run within
that function to bring it up to date with your latest version.
An example of how this function can be used is demonstrated below:
function your_module_name_upgrade($vars) {
$version = $vars['version'];
if ($version=="1.0") {
$query = "ALTER TABLE mod_customtable ADD extrafield TEXT NOT NULL;";
mysql_query($query);
}
}
WHMCS | Addon Module Documentation 12
Useful Resources
Here are some code samples for how to match the styles of WHMCS within your custom
code.
Data Table
Used to output a table of data
<div class="tablebg">
<table class="datatable" width="100%" border="0" cellspacing="1" cellpadding="3">
<tr><th>Col 1</th><th>Col 2</th><th>Col 3</th></tr>
<tr><td>Data Row 1</td><td>Data Row 1</td><td>Data Row 1</td></tr>
<tr><td>Data Row 2</td><td>Data Row 2</td><td>Data Row 2</td></tr>
</table>
</div>
Fields Table
Used to output form fields
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tr><td width="20%" class="fieldlabel">Field Name 1</td><td class="fieldarea">Field
Contents</td></tr>
<tr><td class="fieldlabel">Field Name 2</td><td class="fieldarea">Field Contents</td></tr>
</table>

More Related Content

What's hot

Nguyên nhân dẫn đến việc mất khả năng thanh khoản
Nguyên nhân dẫn đến việc mất khả năng thanh khoản Nguyên nhân dẫn đến việc mất khả năng thanh khoản
Nguyên nhân dẫn đến việc mất khả năng thanh khoản
Nguyễn Ngọc Chánh
 
แผ่นพับ พระอภัยมณี น้ำทิพย์
แผ่นพับ พระอภัยมณี น้ำทิพย์แผ่นพับ พระอภัยมณี น้ำทิพย์
แผ่นพับ พระอภัยมณี น้ำทิพย์
Namthip Apichonsewiyakun
 
แบบรายงานการเดินทาง
แบบรายงานการเดินทางแบบรายงานการเดินทาง
แบบรายงานการเดินทางkrutatee2499
 
Exception handling
Exception handlingException handling
Exception handling
PhD Research Scholar
 
Detonado age of empires
Detonado age of empiresDetonado age of empires
Detonado age of empirespokemon_rede
 
Cartilha SPED Fiscal ICMS/IPI - SEFAZ-GO
Cartilha SPED Fiscal ICMS/IPI - SEFAZ-GOCartilha SPED Fiscal ICMS/IPI - SEFAZ-GO
Cartilha SPED Fiscal ICMS/IPI - SEFAZ-GO
Professor Edgar Madruga
 
Luận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt Nam
Luận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt NamLuận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt Nam
Luận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt Nam
Dịch vụ viết bài trọn gói ZALO 0917193864
 
วิชชุมมาลา ฉันท์ ๘ เสร็จ
วิชชุมมาลา ฉันท์ ๘ เสร็จวิชชุมมาลา ฉันท์ ๘ เสร็จ
วิชชุมมาลา ฉันท์ ๘ เสร็จNat Ty
 
Luận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viên
Luận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viênLuận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viên
Luận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viên
Dịch vụ viết bài trọn gói ZALO: 0909232620
 
Pointers
PointersPointers
Pointers
rajshreemuthiah
 
Presentation on Template Method Design Pattern
Presentation on Template Method Design PatternPresentation on Template Method Design Pattern
Presentation on Template Method Design PatternAsif Tayef
 
VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868
VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868 VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868
VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868
nataliej4
 
บทที่ 4 การอ่านตีความ
บทที่ 4 การอ่านตีความบทที่ 4 การอ่านตีความ
บทที่ 4 การอ่านตีความ
Aj.Mallika Phongphaew
 
แบบระบายสีดอกไม้ประจำชาติอาเซียน
แบบระบายสีดอกไม้ประจำชาติอาเซียนแบบระบายสีดอกไม้ประจำชาติอาเซียน
แบบระบายสีดอกไม้ประจำชาติอาเซียน
Kansinee Kosirojhiran
 
๔. สำนวน สุภาษิต คำพังเพย[1]
๔. สำนวน สุภาษิต คำพังเพย[1]๔. สำนวน สุภาษิต คำพังเพย[1]
๔. สำนวน สุภาษิต คำพังเพย[1]
จุฑารัตน์ ใจบุญ
 
วันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชา
วันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชาวันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชา
วันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชา25Sura
 
Chinese com-vn han ngu q1
Chinese com-vn han ngu q1Chinese com-vn han ngu q1
Chinese com-vn han ngu q1
thúy kiều
 
บทเรียนเรื่อง คำวิเศษณ์
บทเรียนเรื่อง คำวิเศษณ์บทเรียนเรื่อง คำวิเศษณ์
บทเรียนเรื่อง คำวิเศษณ์
ปวริศา
 
ชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความ
ชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความ
ชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความ
Pensri Sangsuk
 

What's hot (20)

Nguyên nhân dẫn đến việc mất khả năng thanh khoản
Nguyên nhân dẫn đến việc mất khả năng thanh khoản Nguyên nhân dẫn đến việc mất khả năng thanh khoản
Nguyên nhân dẫn đến việc mất khả năng thanh khoản
 
แผ่นพับ พระอภัยมณี น้ำทิพย์
แผ่นพับ พระอภัยมณี น้ำทิพย์แผ่นพับ พระอภัยมณี น้ำทิพย์
แผ่นพับ พระอภัยมณี น้ำทิพย์
 
แบบรายงานการเดินทาง
แบบรายงานการเดินทางแบบรายงานการเดินทาง
แบบรายงานการเดินทาง
 
Exception handling
Exception handlingException handling
Exception handling
 
Detonado age of empires
Detonado age of empiresDetonado age of empires
Detonado age of empires
 
Cartilha SPED Fiscal ICMS/IPI - SEFAZ-GO
Cartilha SPED Fiscal ICMS/IPI - SEFAZ-GOCartilha SPED Fiscal ICMS/IPI - SEFAZ-GO
Cartilha SPED Fiscal ICMS/IPI - SEFAZ-GO
 
Luận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt Nam
Luận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt NamLuận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt Nam
Luận án: Nghiên cứu một số truyện thơ của dân tộc Thái ở Việt Nam
 
วิชชุมมาลา ฉันท์ ๘ เสร็จ
วิชชุมมาลา ฉันท์ ๘ เสร็จวิชชุมมาลา ฉันท์ ๘ เสร็จ
วิชชุมมาลา ฉันท์ ๘ เสร็จ
 
Luận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viên
Luận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viênLuận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viên
Luận án: Hoạt động ngôn ngữ nhằm phát triển năng lực của sinh viên
 
Pointers
PointersPointers
Pointers
 
Presentation on Template Method Design Pattern
Presentation on Template Method Design PatternPresentation on Template Method Design Pattern
Presentation on Template Method Design Pattern
 
คำนาม
คำนามคำนาม
คำนาม
 
VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868
VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868 VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868
VĂN HỌC NHẬT BẢN TỪ KHỞI THỦY ĐẾN 1868
 
บทที่ 4 การอ่านตีความ
บทที่ 4 การอ่านตีความบทที่ 4 การอ่านตีความ
บทที่ 4 การอ่านตีความ
 
แบบระบายสีดอกไม้ประจำชาติอาเซียน
แบบระบายสีดอกไม้ประจำชาติอาเซียนแบบระบายสีดอกไม้ประจำชาติอาเซียน
แบบระบายสีดอกไม้ประจำชาติอาเซียน
 
๔. สำนวน สุภาษิต คำพังเพย[1]
๔. สำนวน สุภาษิต คำพังเพย[1]๔. สำนวน สุภาษิต คำพังเพย[1]
๔. สำนวน สุภาษิต คำพังเพย[1]
 
วันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชา
วันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชาวันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชา
วันมาฆบูชา ตอน ๒: แนวคิดเกี่ยวกับวันมาฆบูชา
 
Chinese com-vn han ngu q1
Chinese com-vn han ngu q1Chinese com-vn han ngu q1
Chinese com-vn han ngu q1
 
บทเรียนเรื่อง คำวิเศษณ์
บทเรียนเรื่อง คำวิเศษณ์บทเรียนเรื่อง คำวิเศษณ์
บทเรียนเรื่อง คำวิเศษณ์
 
ชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความ
ชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความ
ชุดกิจกรรม ๒ การคิดวิเคราะห์ บทความ
 

Similar to Whmcs addon module docs

Introduction And Basics of Modules in Drupal 7
Introduction And Basics of Modules in Drupal 7 Introduction And Basics of Modules in Drupal 7
Introduction And Basics of Modules in Drupal 7
Dhinakaran Mani
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabad
php2ranjan
 
Ctools presentation
Ctools presentationCtools presentation
Ctools presentationDigitaria
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
Mage Guru
 
Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)
iFour Technolab Pvt. Ltd.
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
Agusto Sipahutar
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5
Vishwash Gaur
 
The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017
Michael Miles
 
Yii in action
Yii in actionYii in action
Yii in action
KeaNy Chu
 
Joomla Templates101
Joomla Templates101Joomla Templates101
Joomla Templates101
Barb Ackemann
 
Drupal Modules
Drupal ModulesDrupal Modules
Drupal Modules
Amit Kumar Singh
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module developmentRachit Gupta
 
Drupal 7-api-2010-11-10
Drupal 7-api-2010-11-10Drupal 7-api-2010-11-10
Drupal 7-api-2010-11-10Shamsher Alam
 

Similar to Whmcs addon module docs (20)

Introduction And Basics of Modules in Drupal 7
Introduction And Basics of Modules in Drupal 7 Introduction And Basics of Modules in Drupal 7
Introduction And Basics of Modules in Drupal 7
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabad
 
Dashboard
DashboardDashboard
Dashboard
 
Ctools presentation
Ctools presentationCtools presentation
Ctools presentation
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)
 
ASP.NET MVC3 RAD
ASP.NET MVC3 RADASP.NET MVC3 RAD
ASP.NET MVC3 RAD
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5
 
10team
10team10team
10team
 
The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017
 
Yii in action
Yii in actionYii in action
Yii in action
 
Joomla Templates101
Joomla Templates101Joomla Templates101
Joomla Templates101
 
Drupal Modules
Drupal ModulesDrupal Modules
Drupal Modules
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Drupal 7-api-2010-11-10
Drupal 7-api-2010-11-10Drupal 7-api-2010-11-10
Drupal 7-api-2010-11-10
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 

Whmcs addon module docs

  • 1. WHMCS | Addon Module Documentation 1 WHMCS Addon Module Docs Last Updated: 7th December 2010
  • 2. WHMCS | Addon Module Documentation 2 Contents 3. Introduction 4. Getting Started 5. Configuration 6. Activating/Deactivating 7. Content/Output 8. Sidebar 9. Multi-Language 10. Hooks 11. Upgrades 12. Useful Resources
  • 3. WHMCS | Addon Module Documentation 3 Introduction Addon modules allow you to create both admin pages and hooks to extend WHMCS further. Modules can consist of just an admin page, or just hooks, or both. And they are all managed through the Setup > Addon Modules interface. Once activated, the modules will display in a dedicated “Addons” dropdown menu within the admin area for quick & easy access from any page. Management options consist of activating and deactivating of the modules, aswell as access control which allows full admins to define exactly which of the administrator roles are allowed to access each addon module. Why would I use a module for a hook? You might be asking why would I create an admin module when I could just create a hook? And the answer to that would be that creating a module provides an easy way for users to install and remove the addon through the dedicated addon modules
  • 4. WHMCS | Addon Module Documentation 4 Getting Started To get started, you need to begin by choosing a name for your module. This name should be unique among all the modules in WHMCS, and should contain only letters & numbers, all lowercase. Underscores are on the only special characters that are accepted. For example, valid names would be: mymodulename my_module_name my_module_v5 Once you have chosen your name, you need to create a directory and module file for it. The directory should be in the format /modules/addons/your_module_name/ and then the key module file within it should be named “your_module_name.php”. We have created an example module file which you can use as a basis for all your custom modules to help with getting started, and that can be found at the path /modules/addons/addonexample/ within your WHMCS installation. Now let’s move onto customising the module…
  • 5. WHMCS | Addon Module Documentation 5 Configuration The first step in the module is defining the configuration data. This includes the module name, version number, author, description and any configuration fields that might be needed. Below is an example of the config function function: function your_module_name_config() { $configarray = array( 'name' => 'Friendly Display Name Here', 'version' => '1.0', 'author' => 'Your Name Here', 'description' => 'Description of your Addon/Module Here', 'fields' => array( 'username' => array("FriendlyName" => "API Username", "Type" => "text", "Size" => "30", ), 'password' => array("FriendlyName" => "API Password", "Type" => "password", "Size" => "30", ), 'signature' => array("FriendlyName" => "API Signature", "Type" => "password", "Size" => "50", “Description” => “You will find this in your account settings“, ), ), ); return $configarray; } The first 4 fields: name, version, author & description should all be fairly self-explanatory. These just need to contain the name you want displaying within the admin area for your module, version number, your name/company and a brief description of the addon. The fields section is where you can define the input you need from end users to be able to make the module work. In this example we are asking for some API related information. Supported field types are “text”, “password”, “yesno” (checkboxes), “textarea” and “dropdown”. If using the textarea option then you can add a “Rows” parameter to define the height of the box, and if using the dropdown type, then you must specify an “Options” parameter with a comma separated list of values. There is an optional language variable you can also include if you will be using language files for your module - we’ll look at those in more detail later on.
  • 6. WHMCS | Addon Module Documentation 6 Activating/Deactivating Modules can contain both activate and deactivate functions which run when an admin user activates or deactivates the module in the Addon Modules configuration area. These functions can be used to create custom tables, database entries, perform license checks, or anything else you need to run at the time of initial activation or final deactivation. The deactivation function should undo everything that the activation function does in order to fully remove the module from the users system. One point to note is that there will already be an active database connection when the module is run, so to access the WHMCS database you won’t need to reconnect to the database. So for example, the activate and deactivate functions could create and drop a table for use by the custom module as below: function your_module_name_activate() { $query = "CREATE TABLE `mod_customtable` (`id` INT( 1 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,`key` VARCHAR( 16 ) NOT NULL ,`value` TEXT NOT NULL )"; mysql_query($query); } function your_module_name_deactivate() { $query = "DROP TABLE `mod_customtable`"; mysql_query($query); }
  • 7. WHMCS | Addon Module Documentation 7 Content/Output Output from the modules needs to be defined in the function your_module_name_output and should be actually output, (ie. echo’d) not returned. All output will then be captured by WHMCS and displayed within the admin interface template. The module name is automatically prefixed to the output. Variables The output function is passed all of the fields defined in your modules config, along with the values users have set for them, aswell as a “modulelink” variable which you can use to link back to the module. Linking/Actions Using the modulelink variable passed into the output function, you can then create links and forms that post back to your module. The modulelink will be in the format “addonmodules.php?module=xxxxxx” so for links you can then append “&var1=x&var2=y” or with forms you can use the POST form method to receive user input. Within the output function you can then check the $_GET or $_POST variables received in the request in order to display other output or perform various tasks once links have been followed. Admin User Data You can access the currently logged in admin ID should you need that within your module using $_SESSION[‘adminid’] and from that can lookup any additional information you need in tbladmins. Example function your_module_name_output($vars) { $modulelink = $vars['modulelink']; $username = $vars['username']; $password = $vars['password']; echo '<p>Your username is '.$username.'</p>'; }
  • 8. WHMCS | Addon Module Documentation 8 Sidebar An addon module can also define HTML code to be displayed in the sidebar. You can do anything you want with this, but it is ideal for creating custom sub menus specific to a custom module. The function is passed all the same variables as the main content output function, and so can be used like this: function your_module_name_sidebar($vars) { $modulelink = $vars['modulelink']; $username = $vars['username']; $password = $vars['password']; $sidebar = '<span class="header"><img src="images/icons/addonmodules.png" class="absmiddle" width="16" height="16" /> Sample</span> <ul class="menu"> <li><a href="#">Sample Sidebar Link 1</a></li> <li><a href="#">Sample Sidebar Link 2</a></li> </ul>'; return $sidebar; }
  • 9. WHMCS | Addon Module Documentation 9 Multi-Language Modules can be designed to support multiple languages should you wish. For this, the addon module simply needs a lang subfolder creating within it, and within that language files can be created matching the names of the main WHMCS admin area language files located in the /admin/lang/ folder. The language variables for custom modules are kept separate in language files within the module’s own folder to make installation and updating easier. If language files exist, WHMCS will then automatically load these whenever the custom module is accessed, automatically selecting the appropriate language file based on the currently logged in administrators language profile setting. If no matching language file exists within the custom module’s folder for the language the admin is using then it will simply fall back to the default language you set in the module’s config array. The language variables are then passed into both the _output and _sidebar functions variables array using “_lang”. Please refer to the example addon modules language file located in /modules/addons/addonexample/lang/english.php for the format to use for your custom language variables. Below is a demonstration of how you specify the default language for your module in the config array. function your_module_name_config() { $configarray = array( 'name' => 'Friendly Display Name Here', 'version' => '1.0', 'author' => 'Your Name Here', 'description' => 'Description of your Addon/Module Here', 'language' => 'english', 'fields' => array( etc…
  • 10. WHMCS | Addon Module Documentation 10 Hooks To create hooks that your module should define within WHMCS, you simply need to create a file named “hooks.php” within your custom module folder, and that will then be automatically detected and any hooks loaded on every page of WHMCS. The hook functions within that file should be defined in exactly the same way as normal. Please refer to http://wiki.whmcs.com/Hooks for more information on creating hooks.
  • 11. WHMCS | Addon Module Documentation 11 Upgrades Releasing updates and upgrades to your custom modules is likely something you will want to do at some point in time. And if those require modifying the database structure or performing other functions that would otherwise be performed in the _activate function when being activated for the first time, then you need some way of handling that. With the Addon Modules system, this is a breeze with the upgrade function. The upgrade function is called the first time a module is accessed following an update. The update is detected by a change of version number in the _config array of the module, and so if a change is detected, the _upgrade function will be called. The upgrade function is passed the previous version number so that you can then decide what updates you need to run within that function to bring it up to date with your latest version. An example of how this function can be used is demonstrated below: function your_module_name_upgrade($vars) { $version = $vars['version']; if ($version=="1.0") { $query = "ALTER TABLE mod_customtable ADD extrafield TEXT NOT NULL;"; mysql_query($query); } }
  • 12. WHMCS | Addon Module Documentation 12 Useful Resources Here are some code samples for how to match the styles of WHMCS within your custom code. Data Table Used to output a table of data <div class="tablebg"> <table class="datatable" width="100%" border="0" cellspacing="1" cellpadding="3"> <tr><th>Col 1</th><th>Col 2</th><th>Col 3</th></tr> <tr><td>Data Row 1</td><td>Data Row 1</td><td>Data Row 1</td></tr> <tr><td>Data Row 2</td><td>Data Row 2</td><td>Data Row 2</td></tr> </table> </div> Fields Table Used to output form fields <table class="form" width="100%" border="0" cellspacing="2" cellpadding="3"> <tr><td width="20%" class="fieldlabel">Field Name 1</td><td class="fieldarea">Field Contents</td></tr> <tr><td class="fieldlabel">Field Name 2</td><td class="fieldarea">Field Contents</td></tr> </table>