Thanks Paul,
I saw them on the event 2 page but their description is really vague and I couldn’t get what they were meant to do.
Anyway thanks for the tip!
Camille
Thanks Paul,
I saw them on the event 2 page but their description is really vague and I couldn’t get what they were meant to do.
Anyway thanks for the tip!
Camille
If you create a file called 'events.php' in the '/db' subfolder of your plugin and fill it in as described in the docs (with the name of the event and the name of the callback function) and bump your plugin version number (to get Moodle to recognise the changes you have made). Then, when the given event is triggered, the function you specified is called, with the event object as the parameter.
e.g. if you have an events.php file containing:
$observers = array( array( 'eventname' => '\core\event\user_created', 'callback' => '\local_myplugin\event_handler::user_created', ), );
Then, in your plugin's '/classes' subfolder, you create a file 'event_handler.php' and fill it in with:
namespace local_myplugin; class event_handler { public static function user_created(\core\event\user_created $event) { // Do something with this event, probably making use of $event->userid. } }
Then your 'user_created' function will be called immediately after any new user account is created.
Hi Camille,
for a full (and very simple) example that expands on Davo's answer, you can have a look at my "Notify site administrators about new Email Signups" plugin (https://moodle.org/plugins/local_notifyemailsignup). You can browse the code at https://github.com/iarenaza/moodle-local-notifyemailsignup
Saludos. Iñaki.
Thanks Iñaki !
Camille
Thanks Davo for the detailed answer
Camille