如何在Magento中禁用前端注册

Cap*_*ine 11 magento

标题为.

但是,用户仍然可以登录前端,管理员只能在后端创建用户帐户.

liq*_*ity 12

另一种可能性是重载客户/帐户/创建操作,并在调用此操作时将用户重定向到主页.

第一次,只做Ben V.提出的建议.它将删除查看注册页面的可能性.

然后,创建一个新模块,您将在其中重载AccountController.php.

1-在app/code/local/名为Mycompany中创建一个新文件夹

2-在app/code/local/Mycompany/命名的Registrationremove中创建一个新文件夹

3-创建 app/code/local/Mycompany/Registrationremove/etc/

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

在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>
Run Code Online (Sandbox Code Playgroud)

5-创建 app/code/local/Mycompany/Registrationremove/controllers

6-创建 app/etc/modules/Mycompany_Registrationremove.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Registrationremove>
            <active>true</active>
            <codePool>local</codePool>
        </Mycompany_Registrationremove>
    </modules>
</config>
Run Code Online (Sandbox Code Playgroud)

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

在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('*/*');
    }

}
Run Code Online (Sandbox Code Playgroud)

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

复制并粘贴Data.php:

class Mycompany_Registrationremove_Helper_Data extends Mage_Core_Helper_Abstract
{
}
Run Code Online (Sandbox Code Playgroud)

现在,当有人试图访问customer/account/create /时,应将其重定向到主页.

希望有帮助:)

雨果.


Ben*_*enV 5

您可以修改登录屏幕以删除"创建新帐户"按钮.这样,现有用户仍然可以登录,但他们无法创建新帐户.

要修改的文件是/app/design/frontend/default/default/template/customer/form/login.phtml.你会看到第41行<div class="col-1 new-users">.注释掉整个div以隐藏登录页面的"新用户"部分.

编辑:
没有办法像你要求的那样禁用新的用户注册.我做了一点搜索,以及所有我发现几个人用同样的 想法为我的.除了我的原始建议,我会
a)删除<customer_account_create>/app/design/frontend/default/default/layout/custom.xml 的部分,
b)从/ app/design/frontend/default中删除与注册相关的行/default/template/checkout/onepage/login.phtml.

  • 这是处理普通用户的简单方法.但对于高级黑客,他们只需在网址中键入/ customer/account/create /即可进入该帐户创建页面.有没有彻底的解决方案来消除前端注册功能?顺便说一句,我只是不想改变.htaccess设置.我只是想在较低级别而不是根级别处理这个小问题. (2认同)

Cap*_*ine 3

好的。我成功了。参考Hugues Solution,有两处修正:

  1. 添加 app\etc\modules\Mycompany_All.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <Mycompany_Registrationremove>
                <active>true</active>
                <codePool>local</codePool>
            </Mycompany_Registrationremove>
        </modules>
    </config>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 修改文件: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>
    
    Run Code Online (Sandbox Code Playgroud)