Problem displaying alert.

Jake B.

Well-known member
I'm currently working on an addon, and I'm having a problem getting it to display the alerts after a certain action happens. I have created the appropriate rows in xf_content_type, and xf_content_type_field and pointed it towards my AlertHandler, which is being called. But for some reason it will not display the alert. It shows that I have a new alert, but doesn't display it.

Here is my alert handler:
class XenStop_Casino_AlertHandler_Casino extends XenForo_AlertHandler_Abstract
    protected $_postModel = null;
    public function getContentByIds(array $contentIds, $model, $userId, array $viewingUser)
        $betModel = $model->getModelFromCache('XenStop_Casino_Model_Casino');
        return $betModel->getBetsByIds($contentIds);
    protected function _prepareAlertBeforeAction(array $item, $content, array $viewingUser)
            if ($item['extra_data']) {
                $item['extra'] = unserialize($item['extra_data']);
                $item['winlose'] = $item['extra']['win_lose'];
                if($item['winlose'] == 1) {
                    $item['amount'] = intval($item['extra']['bet_amount']) * 2;
                } else {
                    $item['amount'] = $item['extra']['bet_amount'];
        return $item;
    protected function _getDefaultTemplateTitle($contentType, $action) {
        return 'xenstop_casino_alert';
It is selecting all of the rows from in the getContentByIds function, but the _prepareAlertBeforeAction function isn't even running.


1). Did you rebuild the content type cache after you inserted them? Can be done via function rebuildContentTypeCache()
2). In your _prepareAlertBeforeAction() you are unsetting extra_data which function prepareAlert() looks for. Personally I would run you code via the _prepareAction() function (where Action is the action of your alert - such as 'win', 'lose').

Jake B.

Well-known member
1) Yes I did.
2) That isn't the problem, the '_prepareAlertBeforeAction' isn't even running

EDIT: I fixed the issue by removing the unset($item['extra_data']);

Thanks for the assistance @Syndol
Last edited: