Difference between revisions of "Hooks"
m (→Support Tickets) |
(→Hook Points) |
||
Line 22: | Line 22: | ||
===Clients=== | ===Clients=== | ||
− | ClientAdd - userid, firstname, lastname, | + | ClientAdd - userid, firstname, lastname, companyname, email, address1, address2, city, |
− | ClientEdit - userid, firstname, lastname, etc... | + | state, postcode, country, phonenumber, password |
+ | ClientEdit - userid, firstname, lastname, etc... (containing new details), olddata (an array | ||
+ | of previous values) | ||
ClientLogin - userid | ClientLogin - userid | ||
ClientLogout - userid | ClientLogout - userid | ||
Line 34: | Line 36: | ||
===Contacts=== | ===Contacts=== | ||
− | ContactAdd - userid, firstname, lastname, | + | ContactAdd - userid, contactid, firstname, lastname, companyname, email, address1, address2, |
− | + | city, state, postcode, country, phonenumber, subaccount, permissions, | |
+ | domainemails, generalemails, invoiceemails, productemails, supportemails | ||
+ | ContactEdit - same as above | ||
===Products/Services=== | ===Products/Services=== | ||
− | AfterModuleCreate - params | + | AfterModuleCreate - params (an array of vars, same as module functions) |
AfterModuleSuspend - params | AfterModuleSuspend - params | ||
AfterModuleUnsuspend - params | AfterModuleUnsuspend - params | ||
Line 64: | Line 68: | ||
PreShoppingCartCheckout - as above | PreShoppingCartCheckout - as above | ||
AfterShoppingCartCheckout - OrderID, OrderNumber, InvoiceID, Products, Addons, Domains | AfterShoppingCartCheckout - OrderID, OrderNumber, InvoiceID, Products, Addons, Domains | ||
+ | ShoppingCartCheckoutCompletePage - orderid, ordernumber, invoiceid, ispaid, amount, | ||
+ | paymentmethod | ||
AcceptOrder - orderid | AcceptOrder - orderid | ||
CancelOrder - orderid | CancelOrder - orderid | ||
Line 85: | Line 91: | ||
ManualRefund - transid, amount | ManualRefund - transid, amount | ||
AddInvoiceLateFee - invoiceid | AddInvoiceLateFee - invoiceid | ||
+ | InvoicePaymentReminder - invoiceid, type (reminder, firstoverdue, secondoverdue, thirdoverdue) | ||
===Support Tickets=== | ===Support Tickets=== | ||
Line 101: | Line 108: | ||
AdminLogout - adminid | AdminLogout - adminid | ||
AdminHomepage - none, can accept a return of HTML output | AdminHomepage - none, can accept a return of HTML output | ||
+ | AdminAreaClientSummaryPage - none, can accept a return of HTML output | ||
AnnouncementAdd - announcementid, date, title, announcement, published | AnnouncementAdd - announcementid, date, title, announcement, published | ||
AnnouncementEdit - announcementid, date, title, announcement, published | AnnouncementEdit - announcementid, date, title, announcement, published | ||
+ | NetworkIssueAdd - id, startdate, enddate, title, description, type, server, affecting, | ||
+ | server, priority, status | ||
+ | NetworkIssueEdit - same as above | ||
+ | NetworkIssueClose - id | ||
+ | NetworkIssueReopen - id | ||
+ | NetworkIssueDelete - id | ||
+ | ProductEdit - pid, name, description, etc... | ||
+ | ProductDelete - pid | ||
+ | AdminClientFileUpload - userid, title, filename, origfilename, adminonly | ||
===Miscellaneous=== | ===Miscellaneous=== | ||
Line 110: | Line 127: | ||
fraud checks) - orderid, ordernum, amount, paymentmethod, invoiceid, status | fraud checks) - orderid, ordernum, amount, paymentmethod, invoiceid, status | ||
ClientAreaPage - can reference $smarty for defining template vars (no variables) | ClientAreaPage - can reference $smarty for defining template vars (no variables) | ||
+ | AffiliateActivation - affid, userid | ||
+ | EmailPreSend - messagename, relid (accepts an array return | ||
DailyCronJob - can be used to run code daily for custom processes (no variables) | DailyCronJob - can be used to run code daily for custom processes (no variables) |
Revision as of 01:31, 19 May 2011
Action hooks allow you to add your own code that will run when specific actions occur in WHMCS. For example, this can be used for things like performing other actions when an order is placed, sending an SMS message when a support ticket is opened, updating a users details in another application when a change is made in WHMCS, and many more...
Contents
How It Works
Hooks work by creating a file in the includes/hooks folder. Within the file, you need to declare a function that performs the action you want to run. That function will be passed variables from WHMCS, and the values you get depend on the hook being called. All hooks and the variables they will be passed are listed below. After defining your function, you then add the hook to WHMCS which is done by calling the add_hook function:
function create_forum_account($vars) { print_r($vars); } add_hook("ClientAdd",1,"create_forum_account");
- The first part defines the hook point. This must be one of the values from below: ClientAdd, AddInvoicePayment, TicketOpen, etc...
- The number defines the priority so if you have more than 1 hook for the ClientAdd function, the order in which the hooks should run
- The third argument tells WHMCS which function to run at this hook point and so this is the name of the function which you have written in your hook file
Two example hook files are included which you'll find in the hooks folder - one basic example showing the file format and another providing a fully working example of a ClientAdd hook to validate an entered Tax/VAT ID Number.
Hook Points
Below is a full list of hook points you can tap into and the variables that are passed into each one in the $vars array:
Clients
ClientAdd - userid, firstname, lastname, companyname, email, address1, address2, city, state, postcode, country, phonenumber, password ClientEdit - userid, firstname, lastname, etc... (containing new details), olddata (an array of previous values) ClientLogin - userid ClientLogout - userid ClientChangePassword - userid, password ClientDetailsValidation - $_POST ClientClose - userid ClientDelete - userid PreDeleteClient - userid
Contacts
ContactAdd - userid, contactid, firstname, lastname, companyname, email, address1, address2, city, state, postcode, country, phonenumber, subaccount, permissions, domainemails, generalemails, invoiceemails, productemails, supportemails ContactEdit - same as above
Products/Services
AfterModuleCreate - params (an array of vars, same as module functions) AfterModuleSuspend - params AfterModuleUnsuspend - params AfterModuleTerminate - params AfterModuleChangePassword - params AfterModuleChangePackage - params AddonActivation - id, userid, serviceid, addonid PreDomainRegister - params, domain AfterRegistrarRegistration - params AfterRegistrarTransfer - params AfterRegistrarRenewal - params AdminServiceEdit - serviceid CancellationRequest - userid, relid, reason, type AfterProductUpgrade - upgradeid AfterConfigOptionsUpgrade - upgradeid
Order Process
ShoppingCartValidateProductUpdate - runs after updating cart, can use global $errormessage to pass back error ShoppingCartValidateCheckout - runs when checkout is clicked, can use global $errormessage to pass back error PreCalculateCartTotals - products, addons, domains, paymentmethod, etc... PreShoppingCartCheckout - as above AfterShoppingCartCheckout - OrderID, OrderNumber, InvoiceID, Products, Addons, Domains ShoppingCartCheckoutCompletePage - orderid, ordernumber, invoiceid, ispaid, amount, paymentmethod AcceptOrder - orderid CancelOrder - orderid FraudOrder - orderid PendingOrder - orderid DeleteOrder - orderid
Invoicing
InvoiceCreationPreEmail - invoiceid InvoiceCreated - invoiceid InvoicePaid - invoiceid InvoiceUnpaid - invoiceid InvoiceCancelled - invoiceid InvoiceRefunded - invoiceid UpdateInvoiceTotal - invoiceid AddInvoicePayment - invoiceid LogTransaction - date, gateway, data, result AddTransaction - id, userid, currency, gateway, date, description, amountin, fees amountout, rate, transid, invoiceid, refundid ManualRefund - transid, amount AddInvoiceLateFee - invoiceid InvoicePaymentReminder - invoiceid, type (reminder, firstoverdue, secondoverdue, thirdoverdue)
Support Tickets
TicketOpen - ticketid, userid, deptid, deptname, subject, message, priority TicketAdminReply - ticketid, replyid, deptid, deptname, subject, message, priority admin, status TicketUserReply - ticketid, replyid, userid, deptid, deptname, subject, message priority, status TicketOpenAdmin - ticketid, userid, deptid, subject, message, priority TicketAddNote = ticketid, message, adminid
Admin
AdminLogin - adminid AdminLogout - adminid AdminHomepage - none, can accept a return of HTML output AdminAreaClientSummaryPage - none, can accept a return of HTML output AnnouncementAdd - announcementid, date, title, announcement, published AnnouncementEdit - announcementid, date, title, announcement, published NetworkIssueAdd - id, startdate, enddate, title, description, type, server, affecting, server, priority, status NetworkIssueEdit - same as above NetworkIssueClose - id NetworkIssueReopen - id NetworkIssueDelete - id ProductEdit - pid, name, description, etc... ProductDelete - pid AdminClientFileUpload - userid, title, filename, origfilename, adminonly
Miscellaneous
ClientAreaHomepage - none, can accept a return of HTML output ViewOrderDetailsPage - can be used to run code & output in order details view (eg. custom fraud checks) - orderid, ordernum, amount, paymentmethod, invoiceid, status ClientAreaPage - can reference $smarty for defining template vars (no variables) AffiliateActivation - affid, userid EmailPreSend - messagename, relid (accepts an array return DailyCronJob - can be used to run code daily for custom processes (no variables)