How to run custom code when user confirms subscribtion?

Lakjin

Active Member
Hello,

I want to run some custom code after a user confirms their subscription. How can I do that -- where in MailWizz do I have to put my custom code?

Thanks!
 
You could solve it with a callback from an extension/theme like:
PHP:
// this hooks into the lists controller from frontend, and will run before each action.
Yii::app()->hooks->addAction('frontend_controller_lists_before_action', function(CAction $action){
            // see apps/frontend/controllers/ListsController.php Line 451 to see how below event is raised and with what params
            $action->controller->callbacks->onSubscriberSaveSuccess = function(CEvent $event){
                if ($event->params['action'] != 'subscribe-confirm') {
                    return;
                }
                $list = $event->params['list'];
                $subscriber = $event->params['subscriber'];
                // do your custom code from now on.
            };
        });
 
You could solve it with a callback from an extension/theme like:
PHP:
// this hooks into the lists controller from frontend, and will run before each action.
Yii::app()->hooks->addAction('frontend_controller_lists_before_action', function(CAction $action){
            // see apps/frontend/controllers/ListsController.php Line 451 to see how below event is raised and with what params
            $action->controller->callbacks->onSubscriberSaveSuccess = function(CEvent $event){
                if ($event->params['action'] != 'subscribe-confirm') {
                    return;
                }
                $list = $event->params['list'];
                $subscriber = $event->params['subscriber'];
                // do your custom code from now on.
            };
        });
Thanks, I got it to work.
 
Back
Top