Custom Code Hooks Vs. API

Custom Code Hooks Vs. API

Custom Code Hooks (see Tools -> Add-ons) allow you to write custom PHP code that can be triggered when events within NolaPro occur like adding customers or invoices if you want some additional special processing to happen. This is only applicable for users who host themselves. 

You can use the list of Events under Tools -> System -> User Activity Monitor as a guide for what events you can create code hooks for. The code hook trigger title will be the Event name, but in all lower case and separated by periods. AR -> invoice -> update will become ar.invoice.update.

To make a code hook, start a PHP file and at the top register your code hook like the following:

register_custom('ar.invoice.update', 'custom_my_extra_invoice_processing');

You can then create a function called custom_my_extra_invoice_processing($params). The system will drop in parameters that you can use for your special processing like the invoice ID and invoice number in this example.

You can add global $conn; to your function to access the database. ($conn->execute($sql); to run a query)

Place the file in a directory called custom just below the root NolaPro directory.

 

The API serves a different purpose. The API allows you to get data out of and send data into NolaPro. You control when data is sent or pulled out of NolaPro when using the API. The API is not tied to NolaPro events. You can find some general info on the NolaPro API here