I want to create a login page that uses a assigned customer number instead of their email address. The way my business is setup, on a separate eComms platform, they access their account with a customer number because their are multiple account managers for one account. I create accounts for them and then assign a customer number, which they then use to login, with a password.

Any help would be greatly appreciated.

  • I fear that this is too board for this site. Yes it is possible but there would be a lot of rewriting code and changing of templates etc to get this working. Sep 2, 2015 at 9:07
  • Thank you David, I though that this could be the case, but I though it could be worth a shot.
    – Alex W G
    Sep 2, 2015 at 9:23

2 Answers 2


It's possible to implement the basic logic with little custom code:

Write an observer for controller_predispatch_customer_account_loginPost, check if the posted email address (username) does not look like an email address. In this case look up the customer by customer number and replace the username field in the POST data with the actual email address of the found customer.

Example observer code:

$request = $observer->getControllerAction()->getRequest();
$username = $request->getPost('username');
if (false === strpos($username, '@')) {
    $customer = Mage::getModel('customer/customer')
        ->addAttributeToFilter('customer_number', $username)
    if ($customer && $customer->getEmail()) {
        $request->setPost('username', $customer->getEmail());

Then in controller_postdispatch_customer_account_loginPost, replace the email address in the session back to the customer number, if it is set. Otherwise error messages on unsuccessful logins will contain the email address instead of the number.

Example observer code:

$emailAddress = Mage::getSingleton('customer/session')->getUsername();
if ($emailAddress) {
      $customerNumber = Mage::getModel('customer/customer')->loadByEmail($emailAddress)

Other things to consider:

  • Apply same logic to "forgot password" form
  • Decide if you want to use the built in increment_id as customer number, which you can enable in the system configuration under Customer Configuration > Create New Account Options > Generate Human-Friendly Customer ID

Why just numbers...


With this extension you can have people login with user names. Clearly you can lock down those 'user names' to 'account numbers' without too much difficulty.

  • I think this should work. I imaging I will have to do a certain amount of customisation. To get it working how I want.
    – Alex W G
    Sep 2, 2015 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.