Question

I'm new with Magento and I have a problem creating a new account in a Magento 1.7.0. When I input name, email and password and I click in create account it just refreshes the page.

So, I guess, it detect an error and redirects to the same page. First, I don't know which method is being called to register a new customer. I have changed app/code/core/Mage/Customer/controllers/AccountController.php so:

 /**
 * Create customer account action
 */
public function createPostAction()
{
    Mage::log('create post action', null, 'createAccount.log');
    if (!$this->_validateFormKey()) {
        $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
        return;
    }
    Mage::log('validateFormKey() returns true', null, 'createAccount.log');

I thought that _validateFormKey() was returning false and it was redirecting. But createAccount.log file is not being created. So... How can I know which method is being called to create a new user? It would be the first step to detect the error.

I have to say that some days ago I installed the SUPEE-6788 patch, which updated this AccountController.php file.

Was it helpful?

Solution

I guess the problem is that you have also rewritten the customer/form/register.phtml file in your template.

Those templates have been changed by SUPEE-6788.

app/design/frontend/base/default/template/customer/form/register.phtml
app/design/frontend/base/default/template/customer/form/resetforgottenpassword.phtml
app/design/frontend/base/default/template/persistent/customer/form/register.phtml
app/design/frontend/rwd/default/template/customer/form/resetforgottenpassword.phtml
app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml
app/design/frontend/rwd/enterprise/template/customer/form/register.phtml
app/design/frontend/rwd/enterprise/template/persistent/customer/form/register.phtml

A git diff on the following file shows that there was a form key added:

--- a/app/design/frontend/base/default/template/customer/form/register.phtml
+++ b/app/design/frontend/base/default/template/customer/form/register.phtml
@@ -43,6 +43,7 @@
         <div class="fieldset">
             <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
             <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
+            <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
             <h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
             <ul class="form-list">
                 <li class="fields">

What do do?

Edit the customer/form/register.phtml in your template and add the form_key input field.

OTHER TIPS

After upgrading your Magento to 1.9.2.2, or installing security patch SUPEE-6788, it may happen that your customer not able to register themselves. After filling in the registration form and submitting it, the page only refreshes without creating a customer account and without any error message shown.

From Magento 1.9.2.2 or from the security patch SUPEE-6788,magento added a hidden form field with the form_key to the registration form:

<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />

If the form_key field is not present in the registration file the form will not be processed.so since you are using the register.phtml from the custom theme so the upgradation of the magento 1.9.2.2. or installing security patch SUPEE-6788 will not add the form_key field in your custom theme file which results into the just refreshing the registration page wihout creating the customer.

Solution is add the <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /> code to the register.phtml file after open tag used in your custom theme for your shop.

after adding the form key your registration.phtml will look like the below code

<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
<div class="fieldset">
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /> <!-- added -->
app/design/frontend/yourtheme/default/template/persistent/customer/form/register.phtml 

in this file add these after form action.

    <?php echo $this->getBlockHtml('formkey'); ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top