According to Wikipedia, “the term hooking covers a range of techniques used to alter or augment the behavior of an operating system, of applications, or of other software components by intercepting function calls or messages or events passed between software components. Code that handles such intercepted function calls, events or messages is called a hook.”
Here at 123FormBuilder, Hooks allow users to modify the way forms behave. We offer two types of Hooks:
- Hooks that trigger when certain events happen
Trigger external events or integrations, when a specific action happens on the form.
- Hooks that allow the user to alter content based on a desired logic
Make your forms even more dynamic, for example: generate unique coupons, modify fields based on the visitor location, and so on.
How Hooks work
In order to use Hooks, you need to add them in Form Settings > Hooks. You will specify which Hook you want to use and set a Hook URL for it. Then, when the Hook needs to be triggered, we will send a POST request to your Hook URL.
The POST request will send you a JSON, consisting of:
- hook: an array with the following items:
- hookName (string)
- userId (numeric)
- formId (numeric)
- formName (string)
- request: the request parameters, from the originating page ($_POST and $_GET)
- context: various parameters regarding the context of the form (see examples, below). It also includes the IP of the visitor.
- params: the parameters that you can modify, according to your preference.
Please remember that all values contained by these arrays are encoded with base64. With this in mind, in the script that you have chosen to receive the POST requests, you should:
- json_decode the received data, and convert it to an array (let’s name it $arr)
- for each parameter that you want to alter:
- decode it using base64_decode
- alter it as you want
- encode it back, using base64_encode
- encode $arr using json_encode, and output it
Our platform will expect that you return exactly the format already described (hook, context, params). It will consider your Hook failed and continue with the original params if any of these occur:
- your script does not respond within 3 seconds
- your script does not return all the components (hook, context, params)
- we send you N items in params, but your script returns a different number of items
Who can use Hooks
Hooks were released in private beta, on March 15, 2019, for a select list of users.
If you want to request early access, please contact us.