
Elgg has an event system that can be used to replace or add to core functionality. When certain things happen, these events are triggered and handlers than have been registered for them are called. There are two types of events that you can register handlers for: Elgg events and plugin hooks.
Elgg events are triggered when something is created, updated or deleted or when the Elgg framework is loading. Arbitrary events can also be triggered by any plugin. Each event is determined by an event name and an object type (system, user, object, relationship name, annotation, group).
To register for an event, you define a function that takes the event, object type and the object being acted on (if any) as parameters and returns either true or false. A false result will halt the event and prevent any further event handlers from being called. It may also stop code in the core for running; for example it may prevent an entity from being deleted.
See the event reference for details on how to construct your event handler functions and register for a particular event.
Plugin hooks are similar to events. You can register handlers to be run when something happens with plugin hooks just like you can with events. They are different from events in some subtle ways which are covered in the documentation on plugin hooks. The short answer is that plugin hooks are more flexible than elgg events.
It is a good idea to trigger a plugin hook at various points in your plugin. For example a good place is in your actions since another plugin author might wish to expand your functionality. This allows other plugins to add functionality without modifying your code.
See the plugin hooks reference for details on how to construct your plugin hook handler functions and register for a particular hook.