Plugin development

Plugins provide ways of adding functionality to Elgg. This can be as little as a WYSIWYG text editor, or as much as a full feature like a blog engine or a photo gallery.


The basics

Core requirements

Every Elgg plugin sits in a subdirectory of the /mod folder and contains a PHP script called start.php. The name of your subdirectory is your plugin name, so choose carefully! It should be unique but readable, so that site administrators don't accidentally overwrite it with another plugin, but they can also understand at a glance what your plugin does.

Plugin views

Your plugin may have a set of views (see the views reference for plugin-specific information). These may overwrite or extend existing system views.


If you're outputting any system (as opposed to user-entered) text to the screen, we strongly recommend internationalizing using the built-in internationalization functions. See the plugin reference here.


The start.php file is the control hub of any plugin.


We recommend that you use the following skeleton code in your start.php file:

function yourplugin_init() {
    //register actions
    //set up pretty urls
    //add menu items
elgg_register_event_handler('init', 'system', 'yourplugin_init');

Within yourplugin_init you can add calls to define the overall behaviour of your plugin.

Common tasks


During plugin development it is very important to update or disable and re-enable the plugin every time a new view is added. To help developers Cash Costello and Aaron Saray have created the Elgg Development Tools which has the following functionality:

  • Easy options for controlling caching
  • Integrates FirePHP
  • Copies other useful dev settings to one place
  • Plugin skeleton creation
  • View investigation

You may also want to check out Cash Costello's Elgg Coding Standards project and use it with PHP_CodeSniffer to keep yourself aligned with Elgg's official coding guidelines.

Other topics


Search docs