Need help on event handling


I am new to elgg plugin programming and I am currantly doing some small excercises that don't add any great functionality but more for practising reasons.

I don't know what I am doing wrong here, I have been stuck on this for quite a while now: On the event that a user 'friends' another user I want to log the event to the browser log (which is activated). Debuggin with XDebug showed me that my funciton 'new_relationship_log' is not even called. It's probably a very small and stupid error, but I just can't find it. I'd appreciate any kind of help! Thanks!

Here is what the code in start.php of my plugin looks like:


elgg_register_event_handler('init', 'system', 'new_relationship_init');

function new_relationship_init(){
    elgg_register_event_handler('create', 'friend', 'new_relationship_log');

function new_relationship_log($event, $type, $object) {
    elgg_dump("function called");
    $subject = elgg_echo('new_relationship:subject', array($site->name));
    $message = elgg_echo('new_relationship:body', array($name1, $name2));
    elgg_dump("Subject $subject");

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking