Campaigner
Effortlessly subscribe members of your site to Campaign Monitor mailing lists.
30 day money-back guarantee
Extension Hooks
Campaigner includes a two extension hooks:
campaigner_should_subscribe_memberallows you to control whether a specific member should be subscribed to a specific mailing list, overriding Campaigner’s default behaviour.campaigner_subscribe_startallows you to modify the member information that is sent to Campaign Monitor.
campaigner_should_subscribe_member
Parameters
The campaigner_should_subscribe_member hook is called with two parameters:
- An associative array of member information.
- An instance of the
Campaigner_mailing_listclass, containing information about the target mailing list, including the trigger field ID and trigger value. TheCampaigner_mailing_listclass definition can be found atthird_party/campaigner/classes/campaigner_mailing_list.php.
Return values
The campaigner_should_subscribe_member hook handler must return a boolean value. TRUE tells Campaigner to subscribe the specified member to the specified mailing list.
Example hook handler method
/**
* Handles the 'campaigner_should_subscribe_member' hook.
*
* @access public
* @param Array $member_data
* @param Campaigner_mailing_list $list_data
*/
public function on_campaigner_should_subscribe_member(
Array $member_data,
Campaigner_mailing_list $list_data
)
{
// Perform some very clever calculations.
return TRUE; // Subscribe the member.
}
Example extension
A complete and functioning extension is available on our GitHub account.
The extension uses the campaigner_should_subscribe_member hook to implement a common Campaigner feature request: support for “multi-value” trigger fields.
The GitHub repository contains a README file, with further details.
campaigner_subscribe_start
Parameters
The campaigner_subscribe_start extension hook is called with two parameters:
- The ID of the member currently being processed.
- An instance of the
Campaigner_subscriberclass containing information about the current “subscriber.” TheCampaigner_subscriberclass definition can be found atthird_party/campaigner/classes/campaigner_subscriber.php.
Return values
Your campaigner_subscribe_start extension hook handler must return an instance of the Campaigner_subscriber class.
Example hook handler method
/**
* Handles the 'campaigner_subscribe_start' hook.
*
* @access public
* @param Integer $member_id
* @param Campaigner_subscriber $subscriber
* @return Campaigner_subscriber
*/
public function on_campaigner_subscribe_start(
$member_id,
Campaigner_subscriber $subscriber
)
{
// Modify the subscriber data, if required.
return $subscriber;
}