Lesson 4: Doing something when X happens

This lesson explains how to use Elgg's event system.

Problem

Whenever someone joins a group, you want to send an e-mail welcoming them. Whenever a blog entry is posted, you want to be notified so that you can review its content. Whenever someone logs in, you want to increase a counter so that you can proudly post on your front page how many times people have used your site: "3 billion served". In all of these cases, an event occurs and you want something to happen.

Solution

Elgg has an event system that calls a function when something occurs. When a user logs in, a login event is triggered within Elgg. Events are triggered for updating profile fields, joining a group, forming a friendship, uploading a file, ...

Get Elgg 1.8 Social Networking now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.