SPGroup object has a grat property named ContainsCurrentUser. As the name says it tells us if the current user is a member of a group from which property is called. For example, if we want to check if a current user is a member of a “SharePoint Owners” Group we can easily do it like this:

public bool CheckIfUserIsAGroupMember(string groupName)
{
     using(SPSite site = new SPSite(SPContext.Current.Site.ID))
     {
          using(SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
          {
               return web.SiteGroups[groupName].ContainsCurrentUser;
          }
     }
}

But there is a one catch. If You would do this with a SPWeb object gained with the elevated privileges, then the mentioned above code will always return false. Code for the situation like this could look like:

public bool CheckIfUserIsAGroupMember(string groupName)
{
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {
          using(SPSite site = new SPSite(SPContext.Current.Site.ID))
          {
               using(SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
               {
                    return web.SiteGroups[groupName].ContainsCurrentUser;//ALWAYS FALSE!!!
               }
          }
     });
}

To get this solved You can do it like this:

public bool CheckIfUserIsAGroupMember(string groupName)
{
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {
          using(SPSite site = new SPSite(SPContext.Current.Site.ID))
          {
               using(SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
               {
                    try
                    {
                         SPUser user = web.SiteGroups[groupName].Users.GetByID(SPContext.Current.Web.CurrentUser.ID)
                         if(user != null)
                              return true;

                         return false;
                    }
                    catch
                    {
                         return false;
                    }
               }
          }
     });
}