Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:04:43+00:00 2026-06-13T08:04:43+00:00

So during login, I want to check if the user is in a specific

  • 0

So during login, I want to check if the user is in a specific customer group and prevent login if that check fails.

I have extended the AccountController, and added in a quick check:

$customer = Mage::getModel('customer/customer')->loadByEmail($login['username']);
if ($customer->getGroupId() != 2) {
    $msg = Mage::getSingleton('core/session')->addError($this->__('You must have a wholesale account to access this area.'));
    header('Location: '. Mage::getUrl('customer/account/login'));
    exit;
}

However, running this returns session error message, “Customer website ID must be specified when using the website scope”.

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.

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’).

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:04:45+00:00Added an answer on June 13, 2026 at 8:04 am

    You should set website_id before working with loadByEmail method. I know, it seems weird, but this is dictated by the fact, that customer could be a website-scoped entity. So the loadByEmail method will throw exception if customer model is not assigned to any website.

    $customer = Mage::getModel('customer/customer');
    $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
            ->loadByEmail($login['username']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login page (an activity in Android), during which I run an
I've already tried to use Facebook login functionality. During the login I got user
I want login to a flex application that it deployed on jboss 5.1.0 .
In short: How would I check the type of a UI user control during
I have several actions that are protected by filters that check for logged_in? and
In Android, I want to use a custom ProgressDialog box during login without a
So my intention is to have a login in my iOS app that allows
I want to access the role session attribute (which i have set during authentication)
In my application, I want to use oAuth protocol during login processes for several
I have a question that doesn't need any specific answer, just a general direction

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.