Deactivate user registrations in Prestashop

Twitter   Facebook   meneame   reddit   QR   Telegram   Whatsapp

Recently, a friend of mine had the need to create a Prestashop website and to disable the user registration process. He did some searchs and only found paid modules for that, but looking a bit more in forums etc. I found a solution that just fix the needs he had.

First of all we will modify the authentication controller to set newly created users (from the registration form) to be inactive by default. To do so, only have to look for this line in controllers/front/AuthController.php file:

$newuser->active = 1;

And change it's value to 0:

$newuser->active = 0;

This will disable any newly created user (Only in frontend)

The second part is to disable the registration form by commenting it in the authentication template file located in (assuming you're using the default theme) themes/default-bootstrap/authentication.tpl. For that, we can use the { and } special tags in Smarty to wrap signup form code:

{*
  <form action="{$link->getPageLink('authentication', true)|escape:'html':'UTF-8'}" method="post" id="create-account_form" class="box">
    <h3 class="page-subheading">{l s='Create an account'}</h3>
    <div class="form_content clearfix">
      <p>{l s='Please enter your email address to create an account.'}</p>
      <div class="alert alert-danger" id="create_account_error" style="display:none"></div>
      <div class="form-group">
        <label for="email_create">{l s='Email address'}</label>
        <input type="email" class="is_required validate account_input form-control" data-validate="isEmail" id="email_create" name="email_create" value="{if isset($smarty.post.email_create)}{$smarty.post.email_create|stripslashes}{/if}" />
      </div>
      <div class="submit">
        {if isset($back)}<input type="hidden" class="hidden" name="back" value="{$back|escape:'html':'UTF-8'}" />{/if}
        <button class="btn btn-default button button-medium exclusive" type="submit" id="SubmitCreate" name="SubmitCreate">
          <span>
            <i class="icon-user left"></i>
            {l s='Create an account'}
          </span>
        </button>
        <input type="hidden" class="hidden" name="SubmitCreate" value="{l s='Create an account'}" />
      </div>
    </div>
  </form>
*}

And thats all. If a user is created by a "malicious" posting to registration view, it will be disabled, so can not be used, and for the normal users, the registration option will not be shown.