Migrating Default Role Logic Hook

Hello,
I have this logic hook in a sugar 5.5.1 and I’m trying to use it on SuiteCRM 7.3.2. The hook asigns a default role “SinPermisos” to any user created.

=============================================================================

\custom\modules\users\logic_hooks.php:

<?php // Do not store anything in this file that is not part of the array or the hook version. This file will // be automatically rebuilt in the future. $hook_version = 1; $hook_array = Array(); // position, file, function $hook_array['after_login'] = Array(); $hook_array['after_login'][] = Array(1, 'SugarFeed old feed entry remover', 'modules/SugarFeed/SugarFeedFlush.php','SugarFeedFlush', 'flushStaleEntries'); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array(1, 'Rol por defecto para nuevos usuarios', 'custom/modules/Users/UserLogicHook.php','UserLogicHook', 'addInProfile'); ?>

=============================================================================

\custom\modules\users\userlogichook.php:

<?php if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class UserLogicHook { function addInProfile(&$focus, $event, $arguments) { $role_name = "SinPermisos"; $query = "SELECT id FROM users WHERE id = '{$focus->id}'"; $result = $focus->db->query($query, true); if($focus->db->getRowCount($result) == 0) { $query = "SELECT id FROM acl_roles WHERE name = '{$role_name}'"; $result = $focus->db->query($query, true); if($focus->db->getRowCount($result) == 1) { $row = $focus->db->fetchByAssoc($result); $focus->load_relationship('aclroles'); $focus->aclroles->add($row['id']); require_once('modules/ACL/install_actions.php'); } else { sugar_die("Default Role does not exist! Contact the system administrator"); } } } } ?>

=============================================================================

When I enable this on SuiteCrm, I get the “Default Role does not exist! Contact the system administrator” error. Yes, the role is already created.

Testing around in this hook, “select * from acl_roles” and “Select * from users” queries give me getRowCount of 0 results.

What am I doing wrong? I am not very good with php and SugarCRM/SuiteCRM

Thanks