Google+

Pages

Friday, June 22, 2012

How to disable user registration in Magento

There are many situations, when we don't want to allow new users to checkout on our website. In such situations, the question arises, how to remove/ disable registration process from front-end. Try below procedure to do this:

i.      Add app\etc\modules\ Mycode_All.xml

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

 ii.     Then create following folder structure:
        app/code/local/Mycode/etc
        app/code/local/Mycode/Helper
        app/code/local/Mycode/controllers

In app/code/local/Mycode/etc folder, create a new file named config.xml:
Paste below code in it

<?xml version="1.0"?>
<config>
  <modules>
    <Mycode_Registrationremove>
      <version>0.1.0</version>
    </Mycode_Registrationremove>
  </modules>
  <global>
    <rewrite>
      <mycode_registrationremove_account_create>
        <from><![CDATA[#^/customer/account/create$#]]></from>
        <to>/registrationremove/account/create</to>
      </mycode_registrationremove_account_create>
      <mycode_registrationremove_account_createPost>
        <from><![CDATA[#^/customer/account/create/$#]]></from>
        <to>/registrationremove/account/create</to>
      </mycode_registrationremove_account_createPost>
    </rewrite>
  </global>
  <frontend>
    <routers>
      <registrationremove>
        <use>standard</use>
          <args>
            <module>Mycode_Registrationremove</module>
            <frontName>registrationremove</frontName>
          </args>
      </registrationremove>
    </routers>
  </frontend>
</config>
Now create a new file (Data.php) in app/code/local/Mycode/Helper 
folder, and paste below code in it:

<?php 
class Mycode_Registrationremove_Helper_Data extends Mage_Core_Helper_Abstract
{
} ?>
Now create a new file (AccountController.php) in
app/code/local/Mycode/controllers folder:
and paste below code in it:
<?php 
require_once 'Mage/Customer/controllers/AccountController.php';

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





That's all..
It will disable registration process from your website, and when some one will try to go to User Registration page, he/ she will be re-directed to Login page.

But still some things to remove it from every where from your site.
There are two places where you can see button or radio button for 
user registration, which mislead a user that user registration is 
possible.

These two places are:

Login page: Here you see a button named Register

On onepage checkout page: Here you can see a radio button with 
label Register.

You need to hide or remove these also, to completely remove the 
registration process. To do this, go to:

app/design/frontend/[package]/[theme]/template/persistent/checkout/onepage/login.phtml


and comment out following code:

<div class="col-1">
  <h3><?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
<?php echo $this->__('Checkout as a Guest or Register') ?>
<?php else: ?>
<?php echo $this->__('Register to Create an Account') ?>
<?php endif; ?>
  </h3>
  <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
    <p>
      <?php echo $this->__('Register with us for future convenience:') ?>
    </p>
  <?php else: ?>
    <p>
      <strong><?php echo $this->__('Register and save time!') ?></strong>
      <br />
      <?php echo $this->__('Register with us for future convenience:') ?>
    </p>
    <ul>
      <li><?php echo $this->__('Fast and easy check out') ?></li>
      <li>
<?php echo $this->__('Easy access to your order history and status')?>
      </li>
    </ul>
  <?php endif; ?>
  <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
   <ul class="form-list">
     <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
       <li class="control">
        <input type="radio" name="checkout_method" id="login:guest" value="guest"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked"<?php endif; ?> class="radio" />
<label for="login:guest"><?php echo $this->__('Checkout as Guest') ?></label>
       </li>
     <?php endif; ?>
     <li class="control">
       <input type="radio" name="checkout_method" id="login:register" value="register"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->getQuote()->isAllowedGuestCheckout()): ?> checked="checked"<?php endif ?> class="radio" /><label for="login:register"><?php echo $this->__('Register') ?></label>
     </li>
   </ul>
   <h4><?php echo $this->__('Register and save time!') ?></h4>
     <p><?php echo $this->__('Register with us for future convenience:') ?></p>
       <ul class="ul">
         <li><?php echo $this->__('Fast and easy check out') ?></li>
         <li><?php echo $this->__('Easy access to your order history and status') ?></li>
       </ul>
  <?php else: ?>
    <input type="hidden" name="checkout_method" id="login:register" value="register" checked="checked" />
  <?php endif; ?>
</div>

and

<div class="col-1">
  <div class="buttons-set">
    <p class="required">&nbsp;</p>
      <?php if ($this->getQuote()->isAllowedGuestCheckout()): ?>
        <button id="onepage-guest-register-button" type="button" class="button" onclick="checkout.setMethod();">
            <span><span><?php echo $this->__('Continue') ?></span></span>
        </button>
      <?php else: ?>
        <form action="<?php echo $this->getUrl('persistent/index/saveMethod'); ?>">
          <button id="onepage-guest-register-button" type="submit" class="button">
            <span><span><?php echo $this->__('Register') ?></span></span>
          </button>
        </form>
      <?php endif; ?>
  </div>
</div>

Now go to app/design/frontend/[package]/[theme]/template/persistent/customer/form/login.phtml

and comment out following lines:
<div class="col-1 new-users">
    <div class="content">
        <h2><?php echo $this->__('New Customers') ?></h2>
          <p><?php echo $this->__('By creating an account with our store, you will be able to move through the checkout process faster, store multiple shipping addresses, view and track your orders in your account and more.') ?></p>
    </div>
</div>

and

<div class="col-1 new-users">
    <div class="buttons-set">
        <button type="button" title="<?php echo $this->__('Create an Account') ?>" class="button" onclick="window.location='<?php echo Mage::helper('persistent')->getCreateAccountUrl($this->getCreateAccountUrl()) ?>';"><span><span><?php echo $this->__('Create an Account') ?></span></span></button>
   </div>
</div>

That's all.. It will disable user registration from your website.




6 comments:

Gerardo Segura said...

hello, I followed those steps up to modifying the html templates, to see what happens when registration is invoked with the module installed.. but it didn't work, user registration worked ignoring the module. Is there any admin page to list installed modules? I found System > Configuration > Advanced > Disable Modules Output but I don't think is the right place. Otherwise, how can I debug what went wrong with the module?
best regards

J.Little said...

Is this code compatible with the latest version?
These changes do not redirect the registration page as described.

Mohit Kumar Arora said...

Hi Gerardo Segura,

I have tested it Magento Community versions 1.6.0 to 1.6.2.

If you find any problem, you can try this free module of mine.

http://www.magentocommerce.com/magento-connect/medma-disable-registration-5539.html

Anonymous said...

Your free module is for $19 :)

Anonymous said...

This is one of the worst tutorials you can follow to accomplish this. It's simply full of errors and in no way this will work...

Andrew Smith said...

Now try an upgraded version of Module

http://magento-development.medma.net/medma-disable-customer-registration.html