Hi Chris
You may create a logic_hook before_save for module Users.
The logic_hook class may looks like that one:
PHP Code:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class UserLogicHook {
function addInProfile(&$focus, $event, $arguments) {
$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 = '<RoleName>'";
$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("Role '<RoleName>' does not exist! Contact the system administrator");
}
}
}
}
?>
Obviously you need to replace the <RoleName> by the desired Role Name.
Regards
Bookmarks