What is a Hook?
Hooks are one of the most powerful concepts behind Zenbership and understanding them will help you truly unlock the potential of the application.
Basically, a hook is a programmatic event that is triggered when a core function of the application either starts to run or stops running. For example you may want to e-mail someone when a new member registers, or you may want to execute a script which talks to an external API when someone updates their membership details. Hooks make all of this possible.
Types of Hooks
While there are several types of hooks, this documentation, being focussed on extending the program, will only focus on the "PHP Code Execution" type of hook.
- PHP Code Execution: This hook will run a PHP script.
- E-Mail Dispatcher: This hook will trigger the sending of an e-mail to one of more parties.
- MySQL Command Execution: This hook will run a MySQL command.
- Outside Connection: This hook will perform a cURL call to an outside source, such as an API.
Important Things To Remember
- When developing hooks, you need to understand that hooks are executed within the Zenbership environment. This gives you full access to all of Zenbership's core functionality and classes.
- Given that hooks are executed within the lifecycle of a Zenbership process, all hooks need to be non-blocking, meaning you should NEVER execute a exit or die command following the execution of a hook.
Last modified 4 months ago.