Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:32:38+00:00 2026-06-17T08:32:38+00:00

Having issues setting the customers group id from an observer. The event is picking

  • 0

Having issues setting the customers group id from an observer. The event is picking up on a new user creation via customer_register_success event. The event is passed to my observer, e.g.

    public function registrationSuccess(Varien_Event_Observer $observer) {

        // extract customer data from event
        $customer = $observer->getCustomer()->getData();

        Mage::log('COOKIES', json_encode($_COOKIE));

        // a cookie should have been set with the membership id
        if (isset($_COOKIE['membership_account_id'])) {

            Mage::log('COOKIE SET, ASSOCIATING MEMBERSHIP');

            // associate new account with membership, and upgrade user to membership status
            $this->associateMembership($customer['entity_id'], $_COOKIE['membership_account_id']);

        }

    }

Which then calls the associateMembership method to update the group id, and set a custom customer attribute called rms_id:

public function associateMembership($customer_id, $account_id) {

        // load customer model
        $customer = Mage::getModel('customer/customer')->load($customer_id);

        Mage::log('CUSTOMER DATA: ' . json_encode($customer->toArray()));

        // upgrade customer to membership level, and set custom rms_id attribute
        $customer
            ->setWebsiteId(Mage::app()->getWebsite()->getId())
            ->setGroupId(4)
            ->setRmsId($account_id);

        // save
        try {
            $customer->save();
            Mage::log('ACCOUNT ASSOCIATED: CUSTOMER ID = ' . $customer_id . ' ACCOUNT ID = ' . $account_id);
        } catch (Exception $ex) {
            Mage::log($ex);
        }

    }

For some reason, there’s no error coming back. I’m getting the correct user id, and everything seems to be working. However, the group is not being set, nor is my custom id.

Should I be using another event that will allow the save to go through?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:32:39+00:00Added an answer on June 17, 2026 at 8:32 am

    Try loading the website id before loading the customer

    $customer = Mage::getModel('customer/customer')
    $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
    $customer->load($customer_id);
    

    customer_register_success will re-save the customer data after you save it in your custom observer

    Also customer_register_success pass the customer data so you should not need to reload it.

    see /app/code/core/Mage/Customer/controllers/AccountController.php

    Mage::dispatchEvent('customer_register_success',
        array('account_controller' => $this, 'customer' => $customer)
    );
    

    Try

    public function registrationSuccess(Varien_Event_Observer $observer) {
    
        // extract customer data from event
        $customer = $observer->getCustomer();
    
        Mage::log('COOKIES', json_encode($_COOKIE));
    
        // a cookie should have been set with the membership id
        if ($membership_account_id = Mage::getModel('core/cookie')->get('membership_account_id')) {
            Mage::log('COOKIE SET, ASSOCIATING MEMBERSHIP');
    
            $customer->setGroupId(4)
                     ->setRmsId($membership_account_id);
        }
        return $this;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having issues with setting session_set_save_handler. I configured my php.ini to session.handler = user
i'm having issues setting the Image from a dependency property. It seems like the
I'm having issues setting the delegate of a Core Data object to a certain
I'm having issues setting the size of a popup and disabling the location bar
this is my first python project. I am having issues setting up a project
I'm having issues properly setting up my Hibernate configuration. After trying to extend the
I've been having some issues setting up a list of items and moving them
Having issues referencing $(this) from within a the nested ajax 'success' function... I know
I am having issues with setting the Silverlight 4 MediaElement Source property in my
I'm having a few issues with setting the height of a div once the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.