A global webhook instead of per-customer custom webhooks?

Ernesto

Member
Hi, I'd like to have a single webhook to be called when a subscriber subscribes to any list, instead of having each customer customize their own webhook.
Is this possible?

I'm using the List form custom webhooks extension. Or should I do it a different way?
 
@Ernesto - From an extension, you can do something like this:
PHP:
// look in apps/common/extensions/list-form-custom-webhooks/ListFormCustomWebhooksExt.php for detailed usage

if ($this->isAppName('frontend')) {
    Yii::app()->hooks->addAction('frontend_controller_lists_before_action', function($action){
        if (!in_array($action->id, ['subscribe_confirm'])) {
            return;
        }
       
        if (!$action->getController()->asa('callbacks')) {
            return;
        }

        // after the form has been saved successfully, run this function:
        $action->getController()->callbacks->onSubscriberSaveSuccess = function($event){
            // do whatever you wish with the form fields
            $formFields = Yii::app()->request->getPost(null);
           
        };
    });
}
 
Back
Top