Events API

Events API

by Amelia Boli -
Number of replies: 2
Does anyone know where I can ask a question about the Events API? I am specifically trying to figure out if I can trigger adding a new note to the site notes based on the event message_send. Thanks.
Average of ratings: -
In reply to Amelia Boli

Re: Events API

by Onno Schuit -

You could create a local plugin which handles this type of event. In the db directory of your plugin, you'd need to add a events.php file. This file would hold the function name of the event handler, like so:

<?php

$handlers = array (
'user_enrolled' => array (
'handlerfile' => '/local/myplugin/e_handler.php',
'handlerfunction' => 'my_static_class_name::add_site_note',
'schedule' => 'instant',
'internal' => 1,
));

Following this example, you'd need to define a function 'add_site_note' in a static class 'my_static_class' which actually does something with the site notes. The handler function takes one argument: the event data object.

This is all pretty well explained in the dev docs, by the way. See: http://docs.moodle.org/dev/Events_API.

Just let us know if you run into any specific problems.

 

In reply to Onno Schuit

Re: Events API

by roc mehra -

Hi Onno, I want to use message_send event for sending custom message.

I dont know much about code. Please tell me the appropriate files i need to use