2010-06-02 37 views

Trả lời

2

Ok. Tôi hiểu rồi. Tham khảo Hugues Solution, có hai sửa đổi:

  1. thêm ứng dụng \ etc \ modules \ Mycompany_All.xml

    <?xml version="1.0"?> 
    <config> 
        <modules> 
         <Mycompany_Registrationremove> 
          <active>true</active> 
          <codePool>local</codePool> 
         </Mycompany_Registrationremove> 
        </modules> 
    </config> 
    
  2. sửa đổi các tập tin: ứng dụng/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> 
    
+0

Whoups, quên /etc/modules/Mycompany_All.xml :) Và hành động createPost – liquidity

5

Bạn có thể sửa đổi màn hình đăng nhập để xóa nút "Tạo tài khoản mới". Bằng cách này, người dùng hiện tại vẫn có thể đăng nhập nhưng họ không có cách nào để tạo tài khoản mới.

Tệp cần sửa đổi là /app/design/frontend/default/default/template/customer/form/login.phtml. Xung quanh dòng 41 bạn sẽ thấy <div class="col-1 new-users">. Nhận xét toàn bộ div để ẩn phần Người dùng mới của trang đăng nhập.

Chỉnh sửa:
Không có cách nào để vô hiệu hóa đăng ký người dùng mới như bạn đang yêu cầu. Tôi đã tìm kiếm nhiều hơn một chút và tất cả những gì tôi tìm thấy là một số người có số sameidea là của tôi. Ngoài đề xuất ban đầu của tôi, tôi sẽ
a) xóa phần <customer_account_create> của /app/design/frontend/default/default/layout/custom.xml và
b) xóa các dòng liên quan đến đăng ký khỏi/app/thiết kế/lối vào/mặc định/mặc định/template/checkout/onepage/login.phtml.

+2

Đây là cách đơn giản để đối phó với người dùng thông thường. Nhưng đối với hacker tiên tiến, họ có thể làm điều đó đơn giản bằng cách gõ/customer/account/create/trong url để vào trang tạo tài khoản đó. Có bất kỳ giải pháp toàn diện nào để loại bỏ chức năng đăng ký giao diện người dùng không? bằng cách này, tôi chỉ không muốn thay đổi thiết lập .htaccess. Tôi chỉ muốn xử lý vấn đề nhỏ này ở cấp độ thấp hơn là cấp độ gốc. – Capitaine

+0

Bạn phải có một cửa hàng sát thủ nếu mọi người đột nhập vào ;-) Chỉ đùa thôi, tôi hiểu bạn đang tìm kiếm một cách tiếp cận toàn diện sạch sẽ. Thật không may, tôi không nghĩ rằng có một. Xem các chỉnh sửa của tôi ở trên. – BenV

12

Một khả năng khác sẽ là quá tải hành động của khách hàng/tài khoản/tạo và chỉ chuyển hướng người dùng đến trang chủ khi hành động này được gọi.

Lần đầu tiên, chỉ cần làm những gì đã được đề xuất bởi Ben V. Nó sẽ loại bỏ khả năng xem trang đăng ký.

Sau đó, tạo một mô-đun mới mà bạn sẽ làm quá tải AccountController.php.

1- Tạo một thư mục mới trong app/code/local/ tên mycompany

2- Tạo một thư mục mới trong app/code/local/Mycompany/ tên Registrationremove

3 Tạo app/code/local/Mycompany/Registrationremove/etc/

4 Tạo app/code/local/Mycompany/Registrationremove/etc/config.xml

Sao chép và Dán trong 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 Tạo app/code/local/Mycompany/Registrationremove/controllers

6- Tạo 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- Tạo app/code/local/Mycompany/Registrationremove/controllers/Customer/AccountController.php

Copy và Paste trong 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- Tạo app/code/local/Mycompany/Registrationremove/Helper/Data.php

Sao chép và dán vào Data.php:

class Mycompany_Registrationremove_Helper_Data extends Mage_Core_Helper_Abstract 
{ 
} 

Bây giờ, khi ai đó cố gắng truy cập vào khách hàng/tài khoản/tạo/nó sẽ được chuyển đến trang chủ.

Hy vọng rằng đã giúp :)

Hugues.

+0

hi, vui lòng tham khảo http://stackoverflow.com/questions/2959131/how-to-disable-frontend-registration-in-magento/3995507#3995507 – Capitaine

+0

Điều này có hiệu quả. Tuy nhiên, tôi đặt AccountController.php dưới 'controllers /', không phải 'controllers/Customer /' như đã lưu ý. –

+1

Làm việc cho tôi, nhưng phải giữ AccountController.php trong 'controllers/Customer /', và đổi tên lớp thành 'Mycompany_Registrationremove_Customer_Accountcontroller'. –

2

Trong cơ cấu ví dụ trên, tên lớp điều khiển nên được thay đổi từ

lớp Mycompany_Registrationremove_AccountController kéo dài Mage_Customer_AccountController

để

lớp Mycompany_Registrationremove_Customer_AccountController kéo dài Mage_Customer_AccountController

1

Liệu phương pháp này công trình cho ver. 1.4.1.1?

Cuối cùng, tôi quyết định bỏ qua tất cả các bước phức tạp và cũng sửa đổi register.phtml trong \ app \ design \ frontend \ base \ default \ template \ customer \ form, ngoài các tệp mà BenV cho biết.

Tôi đã xóa hình thức và thay đổi tiêu đề để "Đăng ký thành viên khuyết tật" :)

+0

yes it does .... – Capitaine

+0

Có, tôi nghĩ rằng điều này có thể là ý tưởng tốt với thông báo hiển thị "Đăng ký bị vô hiệu hóa" mà không cần sửa đổi không cần thiết nhưng bạn cần sao chép tệp lõi vào vị trí chủ đề của bạn như \ app \ design \ frontend \ YOUR-THEME \ default \ template \ customer \ form \ register.phtml để đăng ký và \ app \ design \ frontend \ YOUR-THEME \ mặc định \ template \ customer \ form \ login.phtml cho Đăng nhập – Anil

1

tôi không thể nhận được bất kỳ trong những giải pháp được đăng ở đây để làm việc, và thấy tôi đã phải sử dụng cú pháp sau trong cấu hình .xml (đặc biệt Frontend router cú pháp):

<?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> 
     <customer> 
      <args> 
       <modules> 
        <Mycompany_Registrationremove before="Mage_Customer">Mycompany_Registrationremove_Customer</Mycompany_Registrationremove> 
       </modules> 
      </args> 
     </customer> 
    </routers> 
</frontend> 
</config> 

có thông tin thêm về phương pháp này ở đây - http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller

0

một luôn có thể thay đổi các bộ định tuyến của khách hàng để trỏ đến một mô-đun mà không cần điều khiển, ví dụ:

<frontend> 
    <routers> 
     <customer> 
      <args> 
       <module>MyModule_NullRouting</module> 
      </args> 
     </customer> 
    </routers> 
</frontend> 
0

Là phần mở rộng cho câu trả lời của thanh khoản, tôi sẽ thực hiện một số thay đổi để cải thiện điều này. Thứ nhất regex không khớp với url nếu nó không có dấu gạch chéo. customer/account/create. Để sửa, các nút "từ" phải đọc <![CDATA[#^/customer/account/create(/.*)?$#]]><![CDATA[#^/customer/account/createPost(/.*)?$#]]>.

Thứ hai, tôi đã bao gồm một người quan sát mà nghe cho sự kiện customer_registration_is_allowed (điều này được gọi trong persistent/customer/form/login.phtml khi sử dụng theme RWD từ $this->helper('customer')->isRegistrationAllowed() chức năng):

<events> 
    <customer_registration_is_allowed> 
     <observers> 
      <your_module_set_is_active> 
       <class>Your_Module_Model_Observers_Customer</class> 
       <method>disableCustomerRegistration</method> 
      </your_module_set_is_active> 
     </observers> 
    </customer_registration_is_allowed> 
</events> 

Sau đó, trong quan sát:

class Your_Module_Model_Observers_Customer 
{ 
    /** 
    * Force disable customer registration 
    * 
    * @param Varien_Event_Observer $observer Observer 
    * @return void 
    */ 
    public function disableCustomerRegistration($observer) 
    { 
     $result = $observer->getResult(); 

     if ($result->getIsAllowed() === true) { 
      $result->setIsAllowed(false); 
     } 
    } 
} 

Bộ này cho phép đăng ký sai và ngăn biểu mẫu đăng ký hiển thị mà không có bất kỳ sửa đổi mẫu nào.

Hy vọng điều này hữu ích!

Các vấn đề liên quan