I got a project In which I have to make a store in which when customer registered email id [email protected] domain then he/she will be consider as premium customer and I have to assign them particular product which only Premium customer can Access and other customer registered with other domain Email id will be general customer and they can not have access to premium product

For this I follow this link How to assign a group to user based on their email id on registration

and created an module based on code but it is not working Here is my Code of


<?xml version="1.0"?>

Then Code for my app\code\local\Xyz\Catalog\etc/config.xml

<?xml version="1.0"?>

And code for my observer is in app\code\local\Xyz\Catalog\Model\Observer/Observer.php

    class Stackexchange_Magento63798_Model_Observer
        public function ChangeCustomerGroup(Varien_Event_Observer $observer){

            Mage::log('My log entry'.$customer->getId(), null, 'Magento63798.log');

            $premiummember=4;// 4 is the id of customer group I have created 
            list($user, $domain) = explode('@',$customer->getEmail());

            if ($domain == 'gmail.com'):
                /* set Customer group as Stiudent */
            // use gmail

But when I registered the user with email id of like of premium member it is not goes into premium member group but goes to general Group

2 Answers 2


You need to change the customergroup before_save

Beside this, you better use customer_register_success. Unfortunately the customer is saved also, so you have to call $customer->save() again.


I have used following codes in my project you can try


<?xml version="1.0"?>

                            <paras_headerchanger before="Mage_Customer">Paras_Headerchanger</paras_headerchanger>




require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';

class Paras_Headerchanger_AccountController extends Mage_Customer_AccountController
     * Get Customer Model
     * @return Mage_Customer_Model_Customer
    protected function _getCustomer()
        $customer = $this->_getFromRegistry('current_customer');
        if (!$customer) {
            $customer = $this->_getModel('customer/customer')->setId(null);
        if ($this->getRequest()->getParam('is_subscribed', false)) {
         * Initialize customer group id
         Get group id

            } else {

        return $customer;

Your Answer

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

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