title: Magento - Get customer group ID of the user logging in before they log in
body: <p>So during login, I want to check if the user is in a specific customer group and prevent login if that check fails.</p>
  
  <p>I have extended the AccountController, and added in a quick check:</p>
  
  <pre><code>$customer = Mage::getModel('customer/customer')-&gt;loadByEmail($login['username']);
  if ($customer-&gt;getGroupId() != 2) {
      $msg = Mage::getSingleton('core/session')-&gt;addError($this-&gt;__('You must have a wholesale account to access this area.'));
      header('Location: '. Mage::getUrl('customer/account/login'));
      exit;
  }
  </code></pre>
  
  <p>However, running this returns session error message, "Customer website ID must be specified when using the website scope".</p>
  
  <p>Basically, I just need to grab the group id of the user who is attempting to login, and I figured I could grab this through the method supplied in the customer model, loadByEmail(). But yeah, it's Friday, and apparently the MageLords want me to stay late.</p>
  
  <p>I have tried a number of methods to get this working, including allowing the login, then checking the ID, then doing $session->logout() if the check fails, but this was preventing me from displaying a session error message since the logout() method is clearing all session messages (including 'core/session'). </p>
  
  <p>Any ideas?</p>