AnsweredAssumed Answered

Using after_relationship_add/delete in Users

Question asked by Cristian Chavez on Aug 29, 2016
Latest reply on Sep 6, 2016 by Cristian Chavez

Hi guys,

I was trying to use the after_relationship_add hook to catch when a Role or a Team is added to an User. I had no problem with Roles, but with Teams, I couldn't make it work.

Here is an example of what I have:

  • The logic_hooks.php file
$hook_version = 1;
$hook_array = Array();

$hook_array['after_relationship_add'] = Array();
$hook_array['after_relationship_add'][] = Array(1, 'Example', 'custom/modules/Users/UsersRelationshipAdd/UsersRelationshipAdd.php','AuditRolesTeamsUsersAdd', 'createAuditRegistry');

$hook_array['after_relationship_delete'] = Array();
$hook_array['after_relationship_delete'][] = Array(1, 'Example', 'custom/modules/Users/UsersRelationshipDelete/UsersRelationshipDelete.php','AuditRolesTeamsUsersDelete', 'createAuditRegistry');



  • And an example of the hook file for the relationship_add event:
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class AuditRolesTeamsUsersAdd{ 
     function createAuditRegistry(&$bean, $event, $args){
          $GLOBALS['log']->fatal("It works!");
          if($args['related_module'] == 'ACLRoles'){
               $GLOBALS['log']->fatal("It works for Roles");
          if($args['related_module'] == 'Teams'){
               $GLOBALS['log']->fatal("It works for Teams");

As I said before, it works for Roles but not for Teams. So, can you tell me if this works in Sugar 6.7?. If not, what other alternative I have for catching what Team was added to an User?




Matt Marum

Tevfik Tümer

Angel Magana