Skip to content

Instantly share code, notes, and snippets.

@eggsurplus
Created October 15, 2015 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eggsurplus/8e548f96947c048935f5 to your computer and use it in GitHub Desktop.
Save eggsurplus/8e548f96947c048935f5 to your computer and use it in GitHub Desktop.
Add a default SecurityGroup for any newly created user
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* Add a default SecurityGroup for any newly created user
*/
class AddSecurityGroup
{
function add_default_group($bean, $event, $arguments)
{
if(empty($bean->id) || $bean->new_with_id == true)
{
$default_group = BeanFactory::getBean('SecurityGroups');
$default_group->retrieve_by_string_fields(array('name'=>'Owner_Only_Group','deleted'=>0));
$default_group->load_relationship('users');
$default_group->users->add($bean->id);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment