I need to add a <select> for the available websites in magento admin at user registration page and associate that customer to the selected website. e.g., if there were 3 websites in magento viz. Main Store, Other Store and Another Store then user will be able to chose any one of them at registration page and associated with that particular website.

I'd been google for a long and found quite similar thing Select Customer Group at Registration but that wasn't helpful to me. Can anybody have any idea on how to do this?

What I've tried till now?
I'd overriden the Customer/AccountController's createPostAction() for adding the selected website in customer model. The code snippet I tried:

$webid = $this->getRequest()->getParam('website_id');
$customer = $this->_getCustomer();
$customer->setData('website_id', $webid); //1st approach
$customer->setWebsiteId($webid); //2nd approach
//3rd approach
$customerForm = $this->_getModel('customer/form');

//and before }

How do I'm getting the website list?

<select name="website_id" id="store_name">
    <option value="">Please select...</option>
    $websites = Mage::app()->getWebsites();
    foreach ($websites as $web) {
        echo "<option value='" . $web->getId() . "'>" . $web->getName() . "</option>\n";

2 Answers 2


The Another Solutions is you can override the Mage_Customer_AccountController Account Controller.

Also in this Controller you got one method as below

 * Create customer account action
public function createPostAction()
       // take whole code of this method and add your set website id code in Object.

Hope you know how to override the Class. then its very simple for you.

  • yeah dear! I'd tried that too but it doesn't worked... see this question Commented Feb 13, 2014 at 4:31
  • I Done this around 3 days ago Its working fine.
    – Keyul Shah
    Commented Feb 13, 2014 at 4:32
  • can you tell me how do you added the website_id? in request post or customer object? Commented Feb 13, 2014 at 4:32
  • because I tried both of them Commented Feb 13, 2014 at 4:33
  • you create one custom customer attribute and create one drop down at registration form and rewrite the module
    – Keyul Shah
    Commented Feb 13, 2014 at 4:34

finally found this answer helpful. But I'd made some changes in the observer where I do needed to get the website id selected by the customer.

Here's the code from my observer

public function setWebsiteId($object) {
    //getting website_id from user selection
    $webid = Mage::app()->getFrontController()->getRequest()
            ->getParam('website_id', Mage::app()->getStore()->getWebsiteId());
    $customer = $object->getCustomer();
    return $this;


The event need to be handled is: customer_register_success


The above code works fine but the problem with the above implementation was, if a user is already registered in the current website then from the current website he will not be able to register in the other website. To solve this problem I'd overridden the Customer/AccountController's createPostAction()

public function createPostAction() {
    $post = $this->getRequest()->getPost();
    if (isset($post['website_id'])) {
        $webid = $this->getRequest()->getParam('website_id');
        $customer = $this->_getCustomer();
        Mage::register('current_customer', $customer); //this is the important line here

If I'm not doing this Mage::register('current_customer', $customer); then the parent createPostAction() will again fetch customer object as $customer = $this->_getCustomer(); and loss website_id which I had set in there previously.

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.