Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Some plugins may need to be invoked to perform certain tasks from time to time, such as when the cron runs. For this reason plugins may register plugin events. These are Events that provide no parameters but will automatically initialize the plugin and invoke the desired callback method when triggered. The parameters passed to the callback method vary depending on the event invoked.

Adding

...

Plugin

...

Events

To add a plugin eventevents, simply invoke Plugins::addEvent() with the appropriate parameters. To remove a plugin event call Plugins::deleteEvent().return them from your plugin's getEvents() method.

Code Block
languagephp
title/install_dir/plugins/my_plugin.php
<?php
class MyPlugin extends Plugin {

	...

	public function getEvents() {
		return array(
			array(
				'event' => "preaction",
				'callback' => array("this", "run")
			)
			// Add multiple events here
		);
	}

	public function run() {
		// This will execute with the "preaction" event is triggered
	}
}
?>