Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable frontend registration in Magento

Tags:

magento

As titled.

But still, users can login to the frontend, and administrator could create user account only in backend.

like image 225
Capitaine Avatar asked Jun 02 '10 15:06

Capitaine


3 Answers

Ok. I got it worked. Refer to Hugues Solution, there are two amendments:

  1. add app\etc\modules\Mycompany_All.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <Mycompany_Registrationremove>
                <active>true</active>
                <codePool>local</codePool>
            </Mycompany_Registrationremove>
        </modules>
    </config>
    
  2. modify the file: app/code/local/Mycompany/Registrationremove/etc/config.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <Mycompany_Registrationremove>
                <version>0.1.0</version>
            </Mycompany_Registrationremove>
        </modules>
     <global>
            <rewrite>
                <mycompany_registrationremove_customer_account_create>
                    <from><![CDATA[#^/customer/account/create/$#]]></from>
                    <to>/registrationremove/customer_account/create</to>
                </mycompany_registrationremove_customer_account_create>
                <mycompany_registrationremove_customer_account_createPost>
                    <from><![CDATA[#^/customer/account/createPost/$#]]></from>
                    <to>/registrationremove/customer_account/createPost</to>
                </mycompany_registrationremove_customer_account_createPost>
            </rewrite>
        </global>
        <frontend>
            <routers>
                <mycompany_registrationremove>
                    <use>standard</use>
                    <args>
                        <module>Mycompany_Registrationremove</module>
                        <frontName>registrationremove</frontName>
                    </args>
                </mycompany_registrationremove>
            </routers>
        </frontend>
    </config>
    
like image 125
Capitaine Avatar answered Oct 01 '22 18:10

Capitaine


Another possibility would be overloading the customer/account/create action and just redirect the user to the home page when this action is invoked.

In a first time, just do what was proposed by Ben V. It will remove the possibility to view the registration page.

Then, create a new module in which you will overload the AccountController.php.

1- Create a new folder in app/code/local/ named Mycompany

2- Create a new folder in app/code/local/Mycompany/ named Registrationremove

3- Create app/code/local/Mycompany/Registrationremove/etc/

4- Create app/code/local/Mycompany/Registrationremove/etc/config.xml

Copy and Paste in config.xml :

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Registrationremove>
            <version>0.1.0</version>
        </Mycompany_Registrationremove>
    </modules>
    <global>
        <rewrite>
             <mycompany_registrationremove_customer_account_create>
                      <from><![CDATA[#^/customer/account/create/$#]]></from>
                      <to>/registrationremove/customer_account/create</to>
                 </mycompany_registrationremove_customer_account_create>
                 <mycompany_registrationremove_customer_account_createPost>
                     <from><![CDATA[#^/customer/account/createPost/$#]]></from>
                     <to>/registrationremove/customer_account/createPost</to>
                 </mycompany_registrationremove_customer_account_createPost>
           </rewrite> 
    </global>

    <frontend>
        <routers>
            <registrationremove>
                <use>standard</use>
                <args>
                    <module>Mycompany_Registrationremove</module>
                    <frontName>registrationremove</frontName>
                </args>
            </registrationremove>
        </routers>
    </frontend>
</config>

5- Create app/code/local/Mycompany/Registrationremove/controllers

6- Create app/etc/modules/Mycompany_Registrationremove.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Registrationremove>
            <active>true</active>
            <codePool>local</codePool>
        </Mycompany_Registrationremove>
    </modules>
</config>

7- Create app/code/local/Mycompany/Registrationremove/controllers/Customer/AccountController.php

Copy and Paste in AccountController.php:

require_once 'Mage/Customer/controllers/AccountController.php';

class Mycompany_Registrationremove_Customer_AccountController extends Mage_Customer_AccountController
{
    public function createAction()
    {
      $this->_redirect('*/*');
    }

    public function createPostAction()
    {
      $this->_redirect('*/*');
    }

}

8- Create app/code/local/Mycompany/Registrationremove/Helper/Data.php

Copy and paste in Data.php:

class Mycompany_Registrationremove_Helper_Data extends Mage_Core_Helper_Abstract
{
}

Now, when someone tries to access to customer/account/create/ it should be redirected to the home page.

Hope that helped :)

Hugues.

like image 12
liquidity Avatar answered Oct 23 '22 14:10

liquidity


You could modify the login screen to remove the "Create New Account" button. This way existing users can still log in but they have no way to create new accounts.

The file to modify is /app/design/frontend/default/default/template/customer/form/login.phtml. Around line 41 you'll see <div class="col-1 new-users">. Comment out that entire div to hide the New User section of the login page.

Edit:
There is no way to just disable new user registration like you are asking. I did a little more searching, and all I found were several people with the same idea as mine. In addition to my original suggestion, I would
a) remove the <customer_account_create> section of /app/design/frontend/default/default/layout/custom.xml, and
b) remove the registration-related lines from /app/design/frontend/default/default/template/checkout/onepage/login.phtml.

like image 5
BenV Avatar answered Oct 23 '22 12:10

BenV