I’ve read a lot of posts (old and new) about extending PrestaShop’s registration form by adding a new field. As far as I know some people had several problems with implementing it.
Today I’m going to show you how to implement it correctly for normal and required field (so you can choose one or both, depending on your needs).
FrontOffice modifications
Let’s start with adding new columns called my_field
and my_field_required
to the ps_customer table . Go to your phpMyAdmin and execute the following SQL command.
ALTER TABLE ps_customer ADD COLUMN my_field VARCHAR(250), ADD COLUMN my_field_required VARCHAR(250)
Now it’s time to edit an authentication template to make our fields visible in the registration form.
Find:
{l s='(Five characters minimum)'}
Add after:
{l s='My field description'}{l s='Required field desc.'}
Of course, you can change the position of new fields and put it wherever you want.
After those modifications, your registration form should look like this:

Next, let’s modify Auth Controller. You have to add there your new fields so it can pass their values to the Customer model and save it to database.
Find:
// Preparing customer $customer = new Customer();
Add after:
$myField = Tools::getValue('my_field'); $myFieldRequired = Tools::getValue('my_field_required'); $customer->my_field = $myField; $customer->my_field_required = $myFieldRequired;
Now, extend your Customer model by adding new columns. You can also add there a validation and determine if the field must be required.
Find:
/** @var string Firstname */ public $firstname;
Add after:
/** @var string my_field */ public $my_field; /** @var string my_field_required */ public $my_field_required;
Find:
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),
Add after:
'my_field' => array('type' => self::TYPE_STRING, 'size' => 256), 'my_field_required' => array('type' => self::TYPE_STRING, 'required' => true, 'size' => 256),
Let’s see how our validation works. Type something in the My field but leave the My required field blank. Next, click the register button placed at the bottom.

Great, the validation works perfectly!
P.S. If you would like to change the error message, check out this tutorial.
Now, fill the My required field and click the register button to create an account.
Of course, it will also save the given values to the database.
That is fair enough, so let’s go to the BackOffice!
BackOffice modifications
From now users can insert values of your fields in registration form and those values are stored in the database.
But there won’t be any new data in the BackOffice > Customers > Customers.
That’s why I will show you what to do to display and edit your new data from the admin panel.
my_field
and my_field_required
fields.
Find:
{if isset($customer->birthday) && $customer->birthday != '0000-00-00'} {l s='%1$d years old (birth date: %2$s)' sprintf=[$customer_stats['age'], $customer_birthday]} {else} {l s='Unknown'} {/if}
Add after:
{if isset($customer->my_field)} {$customer->my_field} {else} {l s='Unknown'} {/if}{if isset($customer->my_field_required)} {$customer->my_field_required} {else} {l s='Unknown'} {/if}
To see your changes, select a customer you’ve created and click View.

It’s simple to make editing possible. You must just add new form fields in the Admin Customers Controller. Look at the code.
Find:
array( 'type' => 'birthday', 'label' => $this->l('Birthday'), 'name' => 'birthday', 'options' => array( 'days' => $days, 'months' => $months, 'years' => $years ) ),
Add after:
array( 'type' => 'text', 'label' => $this->l('My field'), 'name' => 'my_field', 'col' => '4' ), array( 'type' => 'text', 'label' => $this->l('My required field'), 'name' => 'my_field_required', 'required' => true, 'col' => '4' ),
That was easy, right?
Now go to the edit page of the customer you’ve created. You should see something like that:

The good thing is that values of both fields are automatically filled.
Enable editing for users
You may want to let your customers edit their data.
If so, login to your shop with new user credentials, go to “My account” and click:
That’s the form we’re going to modify.
Find:
Add after:
{l s='My field description'}{l s='Required field desc.'}
Add your new field to the BackOffice Customer table
If you wish to display your field in BackOffice Customer table (in the Customers -> Customers tab), you must edit AdminCustomersController and make it aware of the new field.
Find:
$this->_select = '
Add after:
my_field,
Find:
'email' => array( 'title' => $this->l('Email address') ),
Add after:
'my_field' => array( 'title' => $this->l('My field') ),
Save the file and Your table should look like this:
Set overrides
Last and very important thing is to move all Your changes to override/
directory.
1. Copy and paste files:
Source | Destination |
---|---|
controllers/front/AuthController.php | override/controllers/front/AuthController.php |
classes/Customer.php | override/classes/Customer.php |
controllers/admin/AdminCustomersController.php | override/controllers/admin/AdminCustomersController.php |
2. Replace in DESTINATION files:
– class AuthControllerCore extends FrontController
replace with class AuthController extends AuthControllerCore
– class CustomerCore extends ObjectModel
replace with class Customer extends CustomerCore
– class AdminCustomersControllerCore extends AdminController
replace with class AdminCustomersController extends AdminCustomersControllerCore
3. Purge cache:
Remove /cache/class_index.php
file.
And that’s all! Thanks for reading. I hope that everything works as expected.