Troubles with Relationship events

Hi everyone. 

I have written a function with is triggered everytime a friend relationship is created.

elgg_register_event_handler('create', 'relationship', 'friendship_add');

...

function friendship_add($event, $object_type, $relationship){

register_error("test");

}

But there is one problem. My fucntion is triggered even when a friend relationship is not created.  My function is triggered everytime I click on a given user's profile.

I would like to know what's wrong with my code.

Best regards.

 

 

 

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