#327 - Get all members of a team/security group
Hi I want to do something like this where i get all the members of a security group that is associated with an opportunity. is this possible with security suite?
maybe using something like the get_team_members function. Look at the example below:
// include Team class include_once('modules/Teams/Team.php');
$team = new Team(); $team->retrieve('<ID OF THE TEAM>'); $team_members = $team->get_team_members(true);
// Loop through the list foreach($team_members as $user) { // your code here .... }
10 years ago
Hey Rob,
To get the members of a group:
include_once('modules/SecurityGroups/SecurityGroup.php');
$group = new SecurityGroup(); $group->retrieve('IDHERE'); $members = $group->getMembers(); //returns an array of arrays foreach($members as $user) { //do your stuff here }
To get the groups associated to an opportunity: $rel_name = 'SecurityGroups'; //use the link name...can find in cache/modules/{MODULE}/{MODULE}vardefs.php $opportunity->load_relationship($rel_name); $group_ids = $opportunity->$rel_name->get(); if(count($group_ids)>0) { foreach($group_ids as $id) { $group->retrieve($id); } }
10 years ago
cheers dude, just what i wanted.
10 years ago
Awesome! Glad to help.