rotamota Posted June 6, 2011 Share Posted June 6, 2011 This will show you how to add a "how you found us" field to the customer registration. You can easily modify to have additional fields.!!MAKE SURE YOU BACKUP BEFORE DOING ANY MODS!!Modify themes/YOURTHEME/authentication.tplAdd the following at approx line: 328 or where you would like it to display on the registration form. -- Please Select One -- Google MSN Advertisement Other {l s='How did you find us?'} <input name="foundother" type="text" id="foundother" /><label for="foundother">{l s='If found other'} Next Modify controllers/AuthController.phpAdd The following lines approx line 85 under $Customer = new Customer(); $foundother = $_POST['foundother']; $foundus = $_POST['foundus']; Add the following lines to approx lines 145 under $customer-birthday $customer->foundus = $foundus; $customer->foundother = $foundother; Add the following lines to approx lines 178 under self::$cookie->id_customer = (int)($customer->id); self::$cookie->foundus = $customer->foundus; self::$cookie->foundother = $customer->foundother; Add the following lines to approx lines 260 under self::$cookie->id_customer = (int)($customer->id); self::$cookie->foundus = $customer->foundus; self::$cookie->foundother = $customer->foundother; Next Modify classes/Customer.phpAdd the following lines to approx line 30 after public $id; /** @var string Foundus */ public $foundus; /** @var string Foundother */ public $foundother; Add the following lines to approx line 128 after $fields['id_customer'] = (int)($this->id); $fields['foundus'] = pSQL($this->foundus); $fields['foundother'] = pSQL($this->foundother); Next you need to add the new fields to your database. Open phpmyadmin or similar and locate the ps_customer table.You can run the following SQL to add the new fields. Or add them manually. ALTER TABLE `ps_customer` ADD `foundus` VARCHAR( 32 ) NOT NULL , ADD `foundother` VARCHAR( 32 ) NOT NULL DISPLAYING THE DATA IN THE ADMINModify **ADMIN DIRECTORY**/tabs/AdminCustomers.phpREPLACE: 'email' => array('title' => $this->l('E-mail address'), 'width' => 120, 'maxlength' => 19), WITH: 'email' => array('title' => $this->l('E-mail address'), 'width' => 110, 'maxlength' => 19), 'foundus' => array('title' => $this->l('Found us'), 'width' => 20), 'foundother' => array('title' => $this->l('Found Other'), 'width' => 20), This displays the information in the first customer view from within the admin. It also enables you to searchby foundus.Next we want to display the information on the customer view. sectionAdd the following lines to approx line 273 under '.($countBetterCustomers != '-' ? $this->l('Rank: #').''.(int)$countBetterCustomers.' ' : '').' '.$this->l('Found us:').' '. ($customer->foundus).' '.$this->l('Found other:').' '. ($customer->foundother).' Your done, Test and enjoy. 8 Link to comment Share on other sites More sharing options...
pepperoni Posted June 7, 2011 Share Posted June 7, 2011 wow, nice, I haven't tried it yet but I will definitely. Looks like you have thought of everything. well done. Link to comment Share on other sites More sharing options...
Shella Posted June 13, 2011 Share Posted June 13, 2011 Thank, I tried to use this way for another field (default_group_id) and is just BEAUTYFULL.Thanks so much.Shella Link to comment Share on other sites More sharing options...
Apprendista Posted June 17, 2011 Share Posted June 17, 2011 Hi.sorry for my English...I use ver.1.3.2 of prestashop and i dont'have controllers/AuthController.php ...how I do? Please help me!!!! Link to comment Share on other sites More sharing options...
SoulSurfer Posted June 29, 2011 Share Posted June 29, 2011 AWESOME MAN!!!That's exactly what I needed!EDIT:Just one thing, anybody knows how can I insert the same field in ps_address? I want to show that field with the customer address all the time.I’ve been playing with controllers/AddressController.php and controllers/AddressesController.php but I can’t get any result…Any ideas?Thanks! Link to comment Share on other sites More sharing options...
DaggaTora Posted October 8, 2011 Share Posted October 8, 2011 Great!!! Thanks very much rotamota. I still have a problem, in BO tabs a zero appears in Found us and Found Other. any clue? Link to comment Share on other sites More sharing options...
DaggaTora Posted October 8, 2011 Share Posted October 8, 2011 Ok, i dont know why but deleting everything about foundother resolve the thing. Now i'm trying to ad and age verification fiel with a radio button like "I'm over 18" but can make it required. Link to comment Share on other sites More sharing options...
phrasespot Posted March 11, 2012 Share Posted March 11, 2012 Try this free module. No longer available Link to comment Share on other sites More sharing options...
babyewok Posted March 12, 2012 Share Posted March 12, 2012 This works great on Prestashop 1.3.7.0 - how can I also show this info on the order detail tab? Link to comment Share on other sites More sharing options...
babyewok Posted March 21, 2012 Share Posted March 21, 2012 When I installed this I tested it out fully and it was working. Now when someone tries ot register, they get "an error occurred while creating your account message" - what woudl be causing this and why would it happen now when it didn't before? Link to comment Share on other sites More sharing options...
sitte Posted April 20, 2012 Share Posted April 20, 2012 I have the same problem as babyewok. Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted April 23, 2012 Share Posted April 23, 2012 I also attempted to install this on 1.4.7.3 and get "There is 1 error : An error occurred while creating your account." I have tried to figure out what the problem is, but can't find it. Anyone have any ideas? Thanks! Link to comment Share on other sites More sharing options...
babyewok Posted April 23, 2012 Share Posted April 23, 2012 Hi, I did get it working, but honestly can't remember what I did now! I think I found it was a clash with a Facebook login module I had Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted April 23, 2012 Share Posted April 23, 2012 Hmmm.... I disabled all my custom modules, but that did not work. I noticed that there is no mention to assign smarty variables here. Could that be why this isn't working? Link to comment Share on other sites More sharing options...
ilyakar Posted July 2, 2012 Share Posted July 2, 2012 Problem with this tutorial is: If the user doesn't specify the foundother field. Then he gets that "can't create account message". Simply don't use the foundother field... Link to comment Share on other sites More sharing options...
ariom Posted July 2, 2012 Share Posted July 2, 2012 Hi all.... thanks to Rotamota for his tutorial that solved my problem after trying a lot of time to add a custom not required field ( "website" ) in the reg. form.... Now is working quite fine...i inserted the field website in the form and i can see it in Bo if the user compile it.... Two problems: 1 - when the user log in and goes to his address in the account....he cannot see the website name inserted when registered 2 - if he want to modify the address, the field Website is therewithout value and if inserting a new one, this is not changing in the DB and not even in BO Anyone out there has the same or similar problem and find a solution? I use Prestashop vers.1.4.7.3 Thanks in advance for replying Ariom Link to comment Share on other sites More sharing options...
jcasanova Posted November 5, 2012 Share Posted November 5, 2012 I can't edit the custom fields when I'm on the user account !!! HELP!!! Link to comment Share on other sites More sharing options...
badjoker Posted November 7, 2012 Share Posted November 7, 2012 (edited) Are the instructions for Prestashop 1.5 still available ? Before starting to paste all the code pieces, I tried to open all files that need changes and I noticed that a few files from 1.5 are in different paths: Next Modify controllers/AuthController.php which probably became: Next Modify controllers/front/AuthController.php Modify **ADMIN DIRECTORY**/tabs/AdminCustomers.php which probably became: Modify controllers/admin/AdminCustomersController.php Also I'm not sure if other changes must be applied for 1.5 following this instructions. Anybody confirm ? Thanks Edited November 8, 2012 by badjoker (see edit history) Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted November 12, 2012 Share Posted November 12, 2012 Are the instructions for Prestashop 1.5 still available ? Before starting to paste all the code pieces, I tried to open all files that need changes and I noticed that a few files from 1.5 are in different paths: which probably became: Next Modify controllers/front/AuthController.php which probably became: Modify controllers/admin/AdminCustomersController.php Also I'm not sure if other changes must be applied for 1.5 following this instructions. Anybody confirm ? Thanks There were definitely some significant changes from 1.4 to 1.5. I have not tried to implement this in 1.5 myself, but can confirm that things will need to be done a bit differently. Mainly due to them changing file structure, as you mentioned. Link to comment Share on other sites More sharing options...
SupaMonkey Posted November 26, 2012 Share Posted November 26, 2012 Would really be great if OP updated tutorial to accomplish this in 1.5! Link to comment Share on other sites More sharing options...
plauengco Posted November 26, 2012 Share Posted November 26, 2012 I added 'foundother' in $fieldsRequired, $fieldSize & $fieldsValidate arrays. This worked for me under 1.4.9. For exmaple: (1) protected $fieldsRequired = array('foundother', ... (2) protected $fieldsSize = array('foundother' => 32, ... (3) protected $fieldsValidate = array('foundother' => 'isName', ... Link to comment Share on other sites More sharing options...
plauengco Posted December 4, 2012 Share Posted December 4, 2012 also for optional fields: AuthController.php: if (Tools::getValue('foundus')) $foundus = $_POST['foundus']; Customer.php if (Tools::getValue('foundus')) $fields['foundus'] = pSQL($this->foundus); Link to comment Share on other sites More sharing options...
Coldness Posted December 11, 2012 Share Posted December 11, 2012 Can anyone update this tutorial to do this in 1.5 version?? That whould be much appreciated! Thank you Link to comment Share on other sites More sharing options...
ricky11 Posted January 29, 2013 Share Posted January 29, 2013 (edited) Hi All.. Any body found a solution for 1.5 ? how to add fields to the registration process? no guide so far on the internet. come on guys be the first one!!! Edited January 29, 2013 by ricky11 (see edit history) Link to comment Share on other sites More sharing options...
modulesmarket Posted March 1, 2013 Share Posted March 1, 2013 Hello, maybe you would be interested. I've created module that will allow add extra fields to registration form. With that module you can easily create unlimited number of additional fields and sections on top and bottom of the registration form. The advantage of that module is that it doesn't override or change any core files. So further updates of the Prestashop to newer versions wouldn't be a problem. You can check it here: http://addons.presta...tom-fields.html Link to comment Share on other sites More sharing options...
daquity36 Posted April 7, 2013 Share Posted April 7, 2013 I also attempted to install this on 1.4.7.3 and get "There is 1 error : An error occurred while creating your account." I have tried to figure out what the problem is, but can't find it. Anyone have any ideas? Thanks! I had the same problem. The problem was that OP had "NONE" for default value for those added fields. Edit the field's default value to "NULL" and also, check "NULL". This way, even if the customer doesn't specify the field or if the field doesn't get initialized for any reason, the customer can still register without any problems. 1 Link to comment Share on other sites More sharing options...
[email protected] Posted May 9, 2013 Share Posted May 9, 2013 im currently adding new custom fields to users in prestashop 1.5.xx in the front view is easy.... only change the authentification.tpl in your theme folder and add this line: <p class="text"> <label for="custom_1">{l s='custom_1'}</label> <input type="text" class="text" name="custom_1" id="custom_1" value="" /> </p> and next add this line in customer.php controller, in public static $definition = array( : 'custom_1' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), the last step is add custom_1 field in ps_customer table in MYSQL the only task that need is show fields in administration..... Bye Link to comment Share on other sites More sharing options...
erhardz Posted May 31, 2013 Share Posted May 31, 2013 I have successfully done some changes in prestashop 1.5.2.0, please check the modification detail below: Changing the "is required" error message · File: ObjectModel.php · Location: /classes/ · Search: // Checking for required fields · To do: just change the error message text Add/edit field in Create New Account form field :: Add storefront form field · File: authentication.tpl · Location: /themes/xxxxx/ · Search: {$HOOK_CREATE_ACCOUNT_TOP} · To do: Create new input form Add/edit field in Create New Account form field :: Connect to controllers · File: AuthController.php · Location: /controllers/front/ · Search: // Preparing customer · To do: add new line, consist of your new field name, just like $_POST['lastname'] = Tools::getValue('customer_lastname'); Add/edit field in Create New Account form field :: Save to database · File: Customer.php · Location: /classes/ · Search: public static $definition = array( · To do: at the “fields” of customer detail array, add your additional field detail – watch carefully for mandatory field, make sure you add ('required' => true) statementChanging the "is required" error message · File: ObjectModel.php · Location: /classes/ · Search: // Checking for required fields · To do: just change the error message text Add/edit field in Create New Account form field :: Add storefront form field · File: authentication.tpl · Location: /themes/xxxxx/ · Search: {$HOOK_CREATE_ACCOUNT_TOP} · To do: Create new input form Add/edit field in Create New Account form field :: Connect to controllers · File: AuthController.php · Location: /controllers/front/ · Search: // Preparing customer · To do: add new line, consist of your new field name, just like $_POST['lastname'] = Tools::getValue('customer_lastname'); Add/edit field in Create New Account form field :: Save to database · File: Customer.php · Location: /classes/ · Search: public static $definition = array( · To do: at the “fields” of customer detail array, add your additional field detail – watch carefully for mandatory field, make sure you add ('required' => true) statement Link to comment Share on other sites More sharing options...
erhardz Posted May 31, 2013 Share Posted May 31, 2013 Can anybody help me to modify the administrator page? In tab CUSTOMERS - CUSTOMERS, I have succeeded to show my additional fields. But I have 2 problems: 1. VIEW --> I still cannot show my additional detail in the customer's detail page 2. EDIT --> I already success to show my additional field and input field in edit page, but I failed to show the content of the aditional field, and also failed to save the changes Please help me. Thank you in advance. Link to comment Share on other sites More sharing options...
tabutnas Posted June 5, 2013 Share Posted June 5, 2013 Hello , i test solutions of [email protected] erhardz But not work for me.. this should be very simple.. only need pass value.. prestashop delete $_POST whit unset($_POST) T_T Link to comment Share on other sites More sharing options...
AInet Posted March 21, 2014 Share Posted March 21, 2014 Hi I'm starting with PrestaShop - so any corrections and suggestions are welcome. Even more, please take a look at my tutorial and comment. I was trying to add 'sponsor email' field to registration form - sponsor is the one who recommended the shop to another customer. I start with first tutorial in this topic and made it work on ver. 1.5.6.2. - I tested it and it's working for me at front and back. But for sure there are some things to do more about it. For now I did: 1. add field to registration form - sponsor email 2. checking if the email is correct 3. checking if the sponsor's email exist in database 4. sponsor email field is set as required field to do: 5. send email to sponsor with message like : "Someone name, email.. blablabla used your email as a sponsor email in registration proces at 'ShopName' ". If someone have any suggestion at 5. please write. Database Add field to table ps_customer (I added this on the end of the table); sponsor_email; varchar(128); null(yes); the same parameters as email but null is yes For front view File: shop/themes/’theme_name’/authentication.tpl Line: 391, after: <fieldset class="account_creation titled_box"> input: <h2><span>{l s='Your Sponsor email'}</span></h2> <div class="row-fluid"> <div class="span6"> <p class="required text"> <label for="sponsor_email">{l s='Sponsor Email'} <sup>*</sup></label> <input type="email" class="text" id="sponsor_email" name="sponsor_email" value="{if isset($smarty.post.sponsor_email)}{$smarty.post.sponsor_email}{/if}" /> </p> </div> </div> File: shop/controllers/front/AuthController.php Line: 434, after: $customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']); input: $customer->sponsor_email = $sponsor_email; Line: 393, after: // Preparing customer $customer = new Customer(); input: $sponsor_email = $_POST['sponsor_email']; // Checked the sponsor user if exist if (Validate::isEmail($sponsor_email = Tools::getValue('sponsor_email')) && !empty($sponsor_email)) if (!Customer::customerExists($sponsor_email)) $this->errors[] = Tools::displayError('An account with given sponsor email has not been registered.', false); Line: 696, After: /** * Update context after customer creation * @param Customer $customer Created customer */ [..] $this->context->cookie->email = $customer->email; input: $this->context->cookie->sponsor_email = $customer->sponsor_email; File: shop/classes/Customer.php Line: 31, After: class CustomerCore extends ObjectModel { public $id; input: /** @var string sponsor_email */ public $sponsor_email; Line: 168 After: /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'customer', 'primary' => 'id_customer', 'fields' => array( 'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_post' => false), 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), input: 'sponsor_email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), Line: 296, Replace: /** * Return customers list * * @return array Customers */ public static function getCustomers() { $sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname` FROM `'._DB_PREFIX_.'customer` WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' ORDER BY `id_customer` ASC'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } With: /** * Return customers list * * @return array Customers */ public static function getCustomers() { $sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname`, `sponsor_email` FROM `'._DB_PREFIX_.'customer` WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' ORDER BY `id_customer` ASC'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } For back (admin) view File: shop/controllers/admin/AdminCustomers.php Line: 106, after: 'email' => array( 'title' => $this->l('Email address'), 'width' => 140, ), input: 'sponsor_email' => array( 'title' => $this->l('Sponsor Email address'), 'width' => 140, ), Line: 305, After: array( 'type' => 'text', 'label' => $this->l('Email address:'), 'name' => 'email', 'size' => 33, 'required' => true ), input: array( 'type' => 'text', 'label' => $this->l('Sponsor Email address:'), 'name' => 'sponsor_email', 'size' => 33, 'required' => true ), Link to comment Share on other sites More sharing options...
Kami Solutions Posted July 24, 2014 Share Posted July 24, 2014 Does anybody know if there's a module or could tell me how to add a field but the field must be an attachment? For example, when you register you have to fill all the fields and to end the register you attach a file of your ID card and I from the backoffice i can see it. Link to comment Share on other sites More sharing options...
AInet Posted July 24, 2014 Share Posted July 24, 2014 try this http://addons.prestashop.com/en/content-management/7152-custom-fields.html I used it and it worked v.good I'm not sure about adding files (if it's there) but u can contact developer to add this function for u Link to comment Share on other sites More sharing options...
Kami Solutions Posted July 24, 2014 Share Posted July 24, 2014 try this http://addons.prestashop.com/en/content-management/7152-custom-fields.html I used it and it worked v.good I'm not sure about adding files (if it's there) but u can contact developer to add this function for u Thank you for your answer, i've contacted the developer and waiting for his answer. I'll let you guys know. Link to comment Share on other sites More sharing options...
[email protected]. Posted April 19, 2015 Share Posted April 19, 2015 This what I called a proper tutor, although I have yet to try the methods but reading his wiliness and helpful information I am so please to have someone like this on presta board. Well done and thank you! Link to comment Share on other sites More sharing options...
yomas Posted November 25, 2015 Share Posted November 25, 2015 Hello all !Thanks for this subject, it's very interesting ! I'd like to add a customer image (avatar like) in the registration form.This thread talks about text data but how to manage image field upload and storage ?If someone has already manage this it would be great sharing !Thanks in advance for tips ^^ Best regards,Yoann Link to comment Share on other sites More sharing options...
jcdarocha Posted December 10, 2015 Share Posted December 10, 2015 Hi, Somebody did this on PS 1.6 ?? I'm stuck, i can't found any of this line : Add the following lines to approx lines 178 under self::$cookie->id_customer = (int)($customer->id); Thank you!! jC Link to comment Share on other sites More sharing options...
SatishMasani Posted December 24, 2015 Share Posted December 24, 2015 Hello guys a similar topic posted on these website working absolutely fine. Check Out. the following URL: http://prestacraft.com/adding-new-fields-to-the-registration-form/ Hope it helps Link to comment Share on other sites More sharing options...
Rui-PS Posted December 26, 2017 Share Posted December 26, 2017 On 12/24/2015 at 8:53 AM, SatishMasani said: Hello guys a similar topic posted on these website working absolutely fine. Check Out. the following URL: http://prestacraft.com/adding-new-fields-to-the-registration-form/ Hope it helps Hello, we need to have a dropdown menu instead of a text box. Can anyone help us with this? Just need a simple dropdown with yes or no values. Link to comment Share on other sites More sharing options...
Rui-PS Posted December 27, 2017 Share Posted December 27, 2017 23 hours ago, Rui-PS said: Hello, we need to have a dropdown menu instead of a text box. Can anyone help us with this? Just need a simple dropdown with yes or no values. Hello, we need to have a dropdown menu instead of a text box. Can anyone help us with this? Just need a simple dropdown with yes or no values. Hello, could anyone help us with this? Link to comment Share on other sites More sharing options...
ali bakhtiyari Posted September 4, 2019 Share Posted September 4, 2019 hi I have successfully overridden customer class and added my custom fields, and they are stored in DB and showed in BO table. problem is Custom Fields don't appear in update customer info Form in both front office and back office. is there any separated class or controller for these two forms? I've attached two images of the forms. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now