Wondering if I can get user groups
directly after retrieving the user via craft()->users->getUserById($id)
, or if i need to use craft()->userGroups->getGroupsByUserId($id)
also?
As of right now, I'm looping through many users and want to check if they are in a specific group. A rough idea of what I'm looking at now:
// get user (necessary for rest of plugin)
$user = craft()->users->getUserById( $uid );
// get user groups
$user_groups = craft()->userGroups->getGroupsByUserId( $uid );
// check if user is in group
if( in_array("Group_Name", $user_groups) )
{
// do something
}
This works, but when looping through a ton of users, I imagine it would be silly not to first check that I can already get this information from the $user
variable I created. I can't seem to find the answer via documentation. Hoping to get a confirmation from someone!
Thanks