Jump to Content

Objective HTML

Postmaster

The definitive email solution for ExpressionEngine

Hooks API

Overview

The Base Hook class is the class from which all other hooks are extended. To add your own hooks, create a class that extends the Base_hook class.

Hooks Directory
/system/expressionengine/third_party/postmaster/hooks
Class Suffix
_postmaster_hook

Example


class Your_hook_name_postmaster_hook extends Base_hook {
	
	protected $title = 'Your Hook Name';
	
	public function __construct()
	{
		parent::__construct();
	}
	
	public function pre_process()
	{
		// Pre Process Logic
	}
	
	public function trigger()
	{
		// Your trigger logic
		
		$vars = array(
			'var_1' => 'Some Value 1',
			'var_2' => 'Some Value 2',
			'var_3' => 'Some Value 3'
		);
		
		return parent::send($vars);
	}
	
	public function post_process()
	{
		// Post Process Logic
	}
	
}

This a simple example. None of these method are required and will still work if you don't replace them.

Properties

$hook
Actual EE hook name to use
$responses
An array of service response objects

Extends

Postmaster Base API

Methods

display_settings($settings, $obj)

The display_settings method accepts an array of settings used to build a settings form. The parcel and hook obj contains the settings value.

$settings
The settings variable contains a settings array for Interface Builder.
$obj
This is the parcel or hook object which contains the actual settings.
Return

(string) HTML Table of Settings

end_script($response)

Checks a Posmtaster Hook Response object or an array of object for an end_script property. Will return TRUE only if the script should stop.

$response
A valid Postmaster Hook Response
Return

(bool) True or False

get_installed_hooks($hook)

Get the installed hooks for any given hook name.

$hook
A valid hook name
Return

(object) Active Record Object