3

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

abc@gmail.com

He should be automatically assign to student group

and if user registered with the id other then this

gmail.com

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

4

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

<global>
    <events>
        <customer_save_after>
            <observers>
                <change_customer_group>
                    <type>singleton</type>
                    <class>magento63798/observer</class>
                    <method>ChangeCustomerGroup</method>
                </change_customer_group>
            </observers>
        </customer_save_after>
    </events>
</global>       

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

<?php
class Stackexchange_Magento63798_Model_Observer
{
    public function ChangeCustomerGroup(Varien_Event_Observer $observer){

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

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

        if ($domain == 'gmail.com'):
            /* set Customer group as Stiudent */
            $customer->setData('group_id',$StudentGroup);   
        // use gmail
        else:
            $customer->setData('group_id',$GuestGroupId);   
        endif;


    }

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, privacy policy and cookie policy

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