Get Craft UserGroup by ID in Plugin I'm trying to get a record from my database for a UserGroup (although I'm guessing this applies to a few scenarios really - anything that isn't a Craft Element.

I'm still new to plugin development so I could be approaching this entirely wrong but I'm pretty sure I don't want to be using craft()-&gt;db-&gt;createCommand() because it might break in a future version of craft when the schema changes and I also can't do it by using craft()-&gt;elements-&gt;getCriteria(ElementType::UserGroup); because it's not an element.

Is there a best practice for this?
You'll want to go through Craft's service layer to get things like that.

There is a UserGroupsService, which has all sorts of handy methods for retrieving UserGroups like getGroupById() and getGroupByHandle().

You can invoke these from your plugin like:

$userGroup = craft()-&gt;usergroups-&gt;getGroupById(3);
$groupName = $userGroup-&gt;name;


Note that these will return a UserGroupModel populated with your UserGroup information.