How to customize list-unsubscribe header?

@007 - list unsubscribe is just a header, you can modify it via hooks:
PHP:
Yii::app()->hooks->addFilter('console_command_send_campaigns_before_send_to_subscriber', function($emailParams, $campaign, $subscriber, $customer, $server){
    foreach ($emailParams['headers'] as $index => $header) {
        if ($header['name'] == 'List-Unsubscribe') {
            $emailParams['headers'][$index]['value'] = 'Your new header here';
        }
    }
    return $emailParams;
});
 
Thanks @twisted1919
How do I add custom tags into my custom url?

I'd like to do something like this so that I can customize the url per customer:
PHP:
$emailParams['headers'][$index]['value'] = '[CCT_MY_UNSUBSCRIBE_URL]';
 
@007 - In the callback function you have access to following params:
PHP:
function($emailParams, $campaign, $subscriber, $customer, $server)
so you can use them to generate whatever content you have to.
 
  • Like
Reactions: 007
@laurentiu Thanks, that's helpful. I was able to insert the email value using this code:
PHP:
$subscriber['email']
However, could you give me an example of how to get a custom field value? Using the same format as the email, campaign sending gets stuck at the 'sending' status.
 
@007 - $subscriber is an object, which implements the array interface, but the correct way to access stuff is
PHP:
$subscriber->email
Now, to get a custom field value, is pretty simple:
PHP:
$subscriber->getCustomFieldValue('FNAME');
 
@007 - That works for all your list custom fields that are related to subscribers, so FNAME/LNAME/EMAIL/ETC, whatever field defined on your list.
 
@007 - Custom tags, meaning CCT_* ones, right ?
Those are stored in the mw_customer_campaign_tag table, so you can simply query it accordingly ;)
 
Back
Top