tags:

views:

582

answers:

6

As titled.

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

+1  A: 

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.

BenV
Well this is a simple way to deal with normal users. But for advanced hacker they can do it simply by typing /customer/account/create/ in the url to get into that account creation page. Are there any thorough solutions to eliminate the frontend registration function? by the way, I just don't want to change the .htaccess setting. I just want to handle this small problem in lower level rather than root level.
Carson
You must have a killer store if people are hacking to get in ;-) Only kidding, I understand you are looking for a clean comprehensive approach. Unfortunately, I don't think there is one. See my edits above.
BenV
+3  A: 

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_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.

Hugues ALARY
A: 

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>
    
Carson
Whoups, forgot the /etc/modules/Mycompany_All.xml :)And the createPost action
Hugues ALARY
A: 

I have spent hours going over and over this trying to get it to work... But I keep failing... I'm using ver 1.4.1.1 ... the only clue I have is error report, if anyone can shed some light from this, that would be brilliant...

the old consolation is that the error page does achieve my aim of disabling registration ;-)

a:5:{i:0;s:51:"Controller file was loaded but class does not exist";i:1;s:1155:"#0 /var/www/vhosts/traffic.co.uk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(321): Mage::exception('Mage_Core', 'Controller file...') 1 /var/www/vhosts/traffic.co.uk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(288): Mage_Core_Controller_Varien_Router_Standard->_includeControllerClass('/var/www/vhosts...', 'Mycompany_Regis...') 2 /var/www/vhosts/traffic.co.uk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(201): Mage_Core_Controller_Varien_Router_Standard->_validateControllerClassName('Mycompany_Regis...', 'customer_accoun...') 3 /var/www/vhosts/traffic.co.uk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(177): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) 4 /var/www/vhosts/traffic.co.uk/httpdocs/app/code/core/Mage/Core/Model/App.php(304): Mage_Core_Controller_Varien_Front->dispatch() 5 /var/www/vhosts/traffic.co.uk/httpdocs/app/Mage.php(596): Mage_Core_Model_App->run(Array) 6 /var/www/vhosts/traffic.co.uk/httpdocs/index.php(80): Mage::run('', 'store') 7 {main}";s:3:traffic"url";s:25:"/customer/account/create/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

Howie Bailey
The error message is : "Controller file was loaded but class does not exist" which is saying that the file declared as being the controller is correctly loaded, but, the class in that file doesn't exists. Check for typing error in your controller file. The name of the class might be wrong.
Hugues ALARY
+1  A: 

In the above example structure, the controller class name should be changed from

class Mycompany_Registrationremove_AccountController extends Mage_Customer_AccountController

to

class Mycompany_Registrationremove_Customer_AccountController extends Mage_Customer_AccountController

mstalfoort
A: 

Does this method works for ver. 1.4.1.1?

Sergiu