Showing results for 
Search instead for 
Did you mean: 

how to create an new observer on the event “customer_register_success” from the top

how to create an new observer on the event “customer_register_success” from the top

I'm quite newbie in magento. I'm trying to create observer on the event "customer_register_success". I follow the tutorial about how to compose the files in local module. But it didn't work.



When customer register on our website, customer should select the country where they live and it is saved as billing address. The goal i want to meet is that if customer live in United State, their group is standard group(just default group). If not, like live in Jamaica, Spain, they are assigned to international group automatically.



I know that GROUP exist because of tax class tho. but i must make it.



our website's customer group information is, enter image description here



I'm willing to set the groupid based on their country name,id. As you see the following,




enter image description here


First of all, I added a module configuration file to the app/etc/modules directory.



<?xml version="1.0"?>


3) app/code/local/Kbethos/CustomerGrouped/etc/config.xml


<?xml version="1.0" encoding="UTF-8"?>


  class Kbethos_CustomerGrouped_Model_Observer {
  public function customerRegisterSuccess(Varien_Event_Observer $observer) {

 $event = $observer->getEvent();
    $customer = $event->getCustomer();
    $billingAddress = $customer->getPrimaryBillingAddress();

    if ($billingAddress) {
        $countryId = $billingAddress->getCountryId();
        switch ($countryId) {
            case 'US':
                $customer->setData('group_id', 1);
                $customer->setData('group_id', 27);



5) /wh-clone/app/code/local/Kbethos/CustomerGrouped/Helper/Data.php



class Kbethos_CustomerGrouped_Helper_Data extends Mage_Core_Helper_Abstract

What sould i do more? please let me know. Thank you.


Re: how to create an new observer on the event “customer_register_success” from the top

For that you have to load the Customer object and and add the website id too

$customeragain = Mage::getModel("customer/customer")->load($custid);
$website_id = Mage::app()->getWebsite()->getId();   
$customeragain->setData('group_id', 1);
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti