I have created a module to disable user registration (mostly following guide here https://stackoverflow.com/questions/2959131/how-to-disable-frontend-registration-in-magento/25186894).
Unfortunately, I have a strange problem in that the rewrite works if the url is "/customer/account/create" but not if it is "/customer/account/create/" - the trailing slash causes strange behaviour, in that not only is the registration form loaded, but also a 404.
My config.xml consists of:
<?xml version="1.0"?>
<config>
<modules>
<Company_DisableRegistration>
<version>0.1.0</version>
</Company_DisableRegistration>
</modules>
<global>
<rewrite>
<company_disableregistration_customer_account_create>
<from><![CDATA[#^/?customer/account/create/#]]></from>
<to>/disableregistration/customer_account/create</to>
</company_disableregistration_customer_account_create>
<company_disableregistration_customer_account_createPost>
<from><![CDATA[#^/?customer/account/createPost/#]]></from>
<to>/disableregistration/customer_account/createPost</to>
</company_disableregistration_customer_account_createPost>
</rewrite>
</global>
<frontend>
<routers>
<customer>
<args>
<modules>
<Company_DisableRegistration before="Mage_Customer">Company_DisableRegistration_Customer</Company_DisableRegistration>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
This is the first time I've attempted this sort of thing, so I'm not sure what the issue is or how to fix it.
3 Answers 3
I normally use something like
<global>
<rewrite>
<designer_url>
<from><![CDATA[#^/author/id/$#]]></from>
<to><![CDATA[/designer/index/index/id/1ドル]]></to>
<complete>1</complete>
</designer_url>
</rewrite>
</global>
See $# in the end of the original URL and also the complete node.
-
thanks for suggestion. I thought the $ was if part of the url was dynamic (for instance with id). But I tried to add as example and also added teh complete node. Now it no longer shows the register form, however it just 404s - rather than be routed to my custom handler (again, without trailing slash, my custom handler is called). Any other ideas?BrynJ– BrynJ2014年08月07日 16:35:42 +00:00Commented Aug 7, 2014 at 16:35
-
Yeah, try putting both urls wrapped in CDATA.mbalparda– mbalparda2014年08月07日 17:15:29 +00:00Commented Aug 7, 2014 at 17:15
There are some issue with your controller rewrite code
from
<global>
<rewrite>
<company_disableregistration_customer_account_create>
<from><![CDATA[#^/?customer/account/create/#]]></from>
<to>/disableregistration/customer_account/create</to>
</company_disableregistration_customer_account_create>
<company_disableregistration_customer_account_createPost>
<from><![CDATA[#^/?customer/account/createPost/#]]></from>
<to>/disableregistration/customer_account/createPost</to>
</company_disableregistration_customer_account_createPost>
</rewrite>
</global>
to
<global>
<rewrite>
<company_disableregistration_customer_account_create>
<from><![CDATA[#^/customer/account/create/#]]></from>
<to>/disableregistration/customer_account/create</to>
</company_disableregistration_customer_account_create>
<company_disableregistration_customer_account_createPost>
<from><![CDATA[#^/customer/account/createPost/#]]></from>
<to>/disableregistration/customer_account/createPost</to>
</company_disableregistration_customer_account_createPost>
</rewrite>
</global>
As you have using magento old rewrite process ,you did not need this below code,which is used for new controller rewrite process:
More details at :http://www.amitbera.com/how-to-override-a-controller-in-magento/
not needed
<frontend>
<routers>
<customer>
<args>
<modules>
<Company_DisableRegistration before="Mage_Customer">Company_DisableRegistration_Customer</Company_DisableRegistration>
</modules>
</args>
</customer>
</routers>
</frontend>
You need to define your module frontName by Using below code Add standard Company_DisableRegistration_Customer disableregistration
Your AccountController.php file location should be Company>DisableRegistration>Controllers>Customer>
Accountcontroller code is
<?php
require_once Mage::getModuleDir('controllers', "Mage_Customer").DS."AccountController.php";
class Company_DisableRegistration_Customer_AccountController extends Mage_Customer_AccountController
{
}
-
I tried to make the changes you suggested. But after changing the first block and removing the second, entering the url without a forward slash simply serves the standard register page, and with a slash I again get a 404 content output with the register form. I did already have the controller located as you have instructed. Any ideas?BrynJ– BrynJ2014年08月11日 09:07:41 +00:00Commented Aug 11, 2014 at 9:07
I have resolved the issue by amending the config.xml as follows (essentially, removing the global rewrites entirely):
<config>
<modules>
<Reckless_DisableRegistration>
<version>0.1.0</version>
</Reckless_DisableRegistration>
</modules>
<frontend>
<routers>
<customer>
<args>
<modules>
<Reckless_DisableRegistration before="Mage_Customer">Reckless_DisableRegistration_Customer</Reckless_DisableRegistration>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
I would be interested to have my solution further explained to me - does anyone have a link to a resource explaining this syntax in detail?
Explore related questions
See similar questions with these tags.