Add Address To Registration

TL;DR

Thanks to Steven Henk Don

<customer_account_create>
    <reference name="customer_form_register">
        <action method="setShowAddressFields">
            <param>true</param>
        </action>
    </reference>
</customer_account_create>

Longer story

I talked a few days ago with Sascha from melovely.de about old, not more functional or "wrong" answers to "standard" magento questions. I had to add address fields to the customer registration and thought about a observer to do it, but there is an easier way. This is my contribution to replace the google finds with better answers to always the same questions.

Dig in to the controller

I took a look into the Mage_Customer_AccountController and found:

[...]
if ($this->getRequest()->getPost('create_address')) {
[... create address ...]

Deeper into the template

So obviously magento has the option to ask for the address in the registration. A look into the form template brought the finding:

<?php if($this->getShowAddressFields()): ?>
// echo address fields

How to return true?

Ok, how use this method and how to return true?

The "wrong" answers

There is the suggestion to add the XML to your local.xml I prefer not to use the local.xml but this is ok too - if you ask me.

The right answer

Writing an extension is a lot of overkill but does the job. Adding the Setter to the layout or local XML is the way I prefer.

But hacking the core, changing core templates or layout XML files brings a lot of problems while updating!