title: DNN Check if User is in Role Group
body: <p>I'm adding onto my DNN module a check to exclude certain users from having to answer some questions when logging in. Instead of hard coding each individual role I'd like to instead just exclude anyone within a particular role group. That way if we have more roles in the future we can just add them into the role group if we want them to be excluded.</p>
  
  <p>However, I don't know how you check if a user is in role group. I know how to check the role, but not the group if they are in one.</p>
  
  <p>SOLUTION: Here's the code I put together based on the answers I got. Should work.</p>
  
  <pre><code>RoleGroupInfo RoleGrp = RoleController.GetRoleGroupByName(this.PortalId, "Role Group");
  bool bShouldSkipQuestions = false;
  if (RoleGrp != null)
  {
      Dictionary&lt;string, RoleInfo&gt; GroupChk = RoleGrp.Roles;
      if (GroupChk.Count &gt; 0)
      {
          foreach (var item in GroupChk.Values)
          {
              if (_user.IsInRole(item.RoleName))
              {
                  bShouldSkipQuestions = true;
                  break;
              }
          }
      }
  }
  </code></pre>