The standard way to modify the default PocketBase behavior is through event hooks in your Go code.
Each event hook has 3 main public methods:

  • PreAdd(handler) - prepend a new handler function to the specified event hook.
    Returning an error or hook.StopPropagation in the handler function stops the hook execution chain.
  • Add(handler) - append a new handler function to the specified event hook.
    Returning an error or hook.StopPropagation in the handler function stops the hook execution chain.
  • Trigger(data) - triggers the event hook, aka. executes its handlers in the order they were added.
    This method rarely has to be called manually by users.

To remove an already registered hook handler, you can use the handler id that is returned with each Pre/Add registration and pass it to Remove(id) or remove all handlers with RemoveAll() (including system handlers).

You can explore all available event hooks below: