I'm trying to add a script after the customer created a account.

So far I can target the event. But after the event is fired I can't seem to add the script to the next page load. Can someone point me in the right direction?

Cool > Marketing > etc > config.xml


Cool > Marketing > Model > Observer.php

class Cool_Marketing_Model_Observer 

public function createAccount($observer) {

    $block = $this->getLayout()->createBlock(
        array('default' => 'cool/account_create_success.phtml')



1 Answer 1


Your intentions may be misunderstood, but I think regardless of the understanding between the question and solution, you should know the registration success is likely not a template, but instead a session success message.

I'm going to opt out of explaining Magento's framework for doing this, but I'll try to provide a little guidance.

What it seems you may want to investigate, instead, is a bit more complex than you might think, but consider that you may need to author a custom extension. The custom extension is a bit involved, where you would need to rewrite a controller, create/rewrite a block or two, and then typical usage of the theme layouts and templates to render the page. The layouts would need a new handle for your new account registration success route.

An alternative method may also include injecting content via AJAX, but at this point, question the importance of what you are trying to do and see if it can be done elsewhere in the sign-up process.

Observer method

If I am mistaken about your intentions, or that was just example code, then the event you may need to observe is: <customer_register_success> which can be referenced below by following the protected function _dispatchRegisterSuccess($customer) leading to the dispatching of the event you may be aiming to observe.

Within Mage/Customer/controllers/AccountController.php we have:

 * Create customer account action
public function createPostAction()
    // ... code removed for readability

    $customer = $this->_getCustomer();

    try {
        $errors = $this->_getCustomerErrors($customer);

        if (empty($errors)) {

            // NOTE: This may be your desired observer.

        } else {
    } catch (Mage_Core_Exception $e) {
        if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
            $url = $this->_getUrl('customer/account/forgotpassword');
            $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
        } else {
            $message = $this->_escapeHtml($e->getMessage());
    } catch (Exception $e) {
        $session->addException($e, $this->__('Cannot save the customer.'));


Here is the where the dispatched event is done:

 * Dispatch Event
 * @param Mage_Customer_Model_Customer $customer
protected function _dispatchRegisterSuccess($customer)
        array('account_controller' => $this, 'customer' => $customer)

Final Thoughts

Let's consider that there are some development standards with observers, where observers have typical use cases that should be followed. With that said, creating a block, and rendering it within an observer, is probably not something that should be done. I have seen observers used for loading layout xml for updating it, but not so sure about rendering output.

In some cases, observers are passed objects, modified, and require a return of $this.

  • Nice explanation, you understood my question well. Indeed there is a bit more to it, I see now. It was not so much example code, I was using it in my new module.
    – Master Deo
    Apr 6, 2018 at 12:32

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.