I am making a project In which I have to differentiate between the user who have registered I want that if some one registered with the id

[email protected]

He should be automatically assign to student group

and if user registered with the id other then this


then He should be assign to a group say Guest

So can any one tell me. where I have to start for this as I search alot but can not get answer related to this

1 Answer 1


you can do this by magento event Observer and find a trigger an observer on customer save events and change customer group accordingly.

You can try with this two Event

  1. customer_save_before
  2. customer_save_after

First of all ,i guess that you have already create customer groups Student,Guest from Admin>Customers>Customer group.

Find details on event and observer here

Model Approach

Step1: trigger an event on basic of customer_save_before


Step2: Magento Observer Code is below and guess that guest custome group id is 2,Student is 5.

class Stackexchange_Magento63798_Model_Observer
    public function ChangeCustomerGroup(Varien_Event_Observer $observer){

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

        list($user, $domain) = explode('@',$customer->getEmail());

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


See another example How to automatically send a transactional email on customer group change?


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.