Subscribe2 can be configured to send an email to all Administrator level users every time a public subscriber subscriber or unsubscribes. You may want to send these emails but change the list of recipients. The ‘s2_admin_email’ makes that possible.
The hook takes two variables, the list of recipients in array form and the type of email being sent. You can amend the array or completely replace it. You can also carry out different actions for the two email types.
function my_admin_filter($recipients = array(), $email) {
// $recipients is an array of admin email addresses
// $email will be 'subscribe' or 'unsubscribe'
if ($email == 'subscribe') {
foreach ($recipients as $key => $email) {
if ( $email == '[email protected]') {
unset($recipients[$key]);
}
}
$recipients[] = '[email protected]';
}
return $recipients;
}
add_filter('s2_admin_email', 'my_admin_filter', 10, 2);