DragonByte Tech
Well-known member
Currently, there's no way for EmailStop handlers to ask users for feedback after unsubscription.
Asking for feedback is a very common tactic in email lists; you click unsubscribe, and you are instantly unsubscribed - but it says something like "You've been unsubscribed. You can now close this window, but if you want to tell us why you unsubscribed:" and then a list of options.
In order to achieve this now, we have to extend \XF\Pub\Controller\EmailStop and do the dreaded "full method replacement, something like:
(Obviously quite incomplete )
If this would be too much work for too little gain, it may be worth creating a new code event in that location that can intercept the return message and return an alternative message instead, by changing the
I would say that passing the controller (
Fillip
Asking for feedback is a very common tactic in email lists; you click unsubscribe, and you are instantly unsubscribed - but it says something like "You've been unsubscribed. You can now close this window, but if you want to tell us why you unsubscribed:" and then a list of options.
In order to achieve this now, we have to extend \XF\Pub\Controller\EmailStop and do the dreaded "full method replacement, something like:
PHP:
public function actionIndex(ParameterBag $params)
{
if ($this->isPost())
{
$confirmKey = $this->filter('c', 'str');
$emailStopper = $this->assertValidatedStopService($params->user_id, $confirmKey);
$stopAction = $this->filter('stop', 'str');
$parts = explode(':', $stopAction, 2);
if ($parts[0] == 'dbtech_mail_mailinglist')
{
$emailStopper->stop($stopAction);
$viewParams = [
'user' => $emailStopper->getUser(),
'confirmKey' => $emailStopper->getConfirmKey()
];
return $this->view('DBTech\Mail:EmailStop\Feedback', 'dbtech_mail_unsubscribe_feedback', $viewParams);
}
}
return parent::actionIndex($params);
}
If this would be too much work for too little gain, it may be worth creating a new code event in that location that can intercept the return message and return an alternative message instead, by changing the
return $this->message(\XF::phrase('your_email_notification_selections_have_been_updated'));
line to store that message in a variable instead.I would say that passing the controller (
$this
), the $stopAction
variable, the $emailStopper
service and the &$retval
variable containing the message would be a good set of parameters.Fillip
Upvote
3