Block sending mails for some users

Alexander

New Member
Hello twisted1919 and other users.
I want write new extensions and have some questions:

1. I want to block sending emails for some users in campaign by my rules. I find sending in apps/console/commands/SendCampaignsCommand.php:482 but in processSubscribersLoop($params) has no events to block sending.
Can I add:
PHP:
$subscribers = $this->findSubscribers($offset, $limit);
//add event
$subscribers = Yii::app()->hooks->applyFilters('console_command_send_campaigns_after_find_subscribers', $subscribers, $campaign);
Or in any another place to disable sending to subscriber.
2. How can I override some core classes. Know how I can overwrite Controllers by controllerMap. How can I override Console commands (question 1) or core models?
3. Is it possible extend view (not replace)?
4. For example: different extensions override same controller. After that work only code from last extension not both?
 
Last edited:

twisted1919

Administrator
Staff member
@Alexander
1. If you only skip the subscribers, these subscribers will be selected for sending in the next run, eventually you will end up with only skipped subscribers and sending will be blocked. Best is to implement your login the that method by extending the SendCampaignsCommand like shown below.
2. You can override console commands by simply adding a file main-custom.php in apps/console/config/ folder and in it, simply replace one of the core commands, as in:
Code:
return array(
    'commandMap' => array(
        'send-campaigns' => array(
            'class' => 'console.commands.MySendCampaignsCommand'
        ),
    ),
);
And above, your "MySendCampaignsCommand" will extend the core "SendCampaignsCommand" command in which you can override only certain methods.
As far as models, you have to create yours, extend from the core ones, and call yours instead of calling the core ones.

3. No

4. That is correct.
 
Top