We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

binding to new comments | Forum

Jocke
Jocke Sep 23 '14
Hi,


How do I do to get a custom function to trigger when a new comment is added on newsfeed, photos, movies and such


I tried 

$em = OW::getEventManager();$em->bind('base_add_comment', 'myFunction');

But it does not trigger, please help.

Sean
Sean Sep 26 '14
OW::getEventManager()->bind('base_add_comment',array($this, 'onAddComment'));

Replace 'onAddComment' with the function you want to call.

public function onAddComment(OW_Event $event)
    {
        $params = $event->getParams();

        if(empty($params['entityType'])){
            return;
        }

        //DO WHATEVER
    }
Sean
Sean Sep 26 '14
You should add this to the init.php file of the plugin you're developing.