JungleJap Posted October 26, 2010 Share Posted October 26, 2010 Hello there,I've modified the customer registration and added a pulldown menu on the registration page so that a customer can choose the group they belongs to.While this works fine, I would like to set the "Default Group" to the one a customer selects. I've looked through files related to the registration process but could not work out how to achieve this.Could anyone tell me where to change and how?Thanks in advance,Rio Link to comment Share on other sites More sharing options...
rocky Posted October 27, 2010 Share Posted October 27, 2010 When creating the customer object, write: $customer->id_default_group = 2; Change 2 to the default customer group of the customer. Link to comment Share on other sites More sharing options...
JungleJap Posted October 27, 2010 Author Share Posted October 27, 2010 Hi Rocky,Thanks for the reply. I'm still new to PrestaShop and not 100% sure what 'm doing.Can you tell me where should the code you mentioned go in? Will it be in the file "authentication.php"?Also I noticed that in the file "classes/Customer.php", with in the function "add", there is a line that states: $this->id_default_group = 1; Will the code you mentioned override this? Link to comment Share on other sites More sharing options...
rocky Posted October 27, 2010 Share Posted October 27, 2010 I didn't notice that code. That prevents you from changing the default customer group. You will need to remove that line before you can change the default customer group. I wonder why the PrestaShop team decided to do that? Link to comment Share on other sites More sharing options...
JungleJap Posted October 27, 2010 Author Share Posted October 27, 2010 Hi rocky,Thank you for your input. It's been sorted out and all working now I've inserted a piece of code below in authenticate.php, $customer->id_default_group = (empty($_POST['group']) ? 1 : intval($_POST['group'])); and commented out the aforementioned line in Customer.phpCheers! Link to comment Share on other sites More sharing options...
rocky Posted October 27, 2010 Share Posted October 27, 2010 Great. Please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
paoltaia Posted December 8, 2010 Share Posted December 8, 2010 Hi guys,I'd need to do exactly the same thing, but I'm not good enough to implement it by myself... Could you be kind enough to share with a lil tutorial how this has been achieved?I'd be really really grateful!Paolo Link to comment Share on other sites More sharing options...
deep42 Posted June 7, 2011 Share Posted June 7, 2011 Hello,I'm experiencing similar problems, in the sense that the user does get correctly added to the second group (discount, tax excl. etc.), but the default groups still remains #1. Which should theoretically be a glitch (and actually is: if I edit the newly registered customer without changing anything, I get the standard error: Default customer group must be selected in group box.).I've changed the following:> in AuthController.php (PS 1.4), in the if (!$customer->add()) paragraph: if (Tools::getValue('dni') != '') {$customer->addGroups(array(2)); customer->id_default_group = 2;} > in Customer.php: I've commented the line that is mentioned in the 3rd reply, above [$this->id_default_group = 1;]Any suggestions? Thank you. Link to comment Share on other sites More sharing options...
deep42 Posted June 7, 2011 Share Posted June 7, 2011 Scratch that, I found a solution here: http://www.prestashop.com/forums/viewthread/2395/P45/third_party_modules/eu_vat_module if (Tools::getValue('dni') != '') { $customer->cleanGroups(); $customer->addGroups(array(2)); $customer->id_default_group = 2; $row = array('id_default_group' => intval($customer->id_default_group)); Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer', $row, 'UPDATE', "email='".$customer->email."'", 1); } Link to comment Share on other sites More sharing options...
Fastarrow Posted May 21, 2012 Share Posted May 21, 2012 Hi there, I don´t want to set new topics so I am asking here pls I need to change user group after customer buy virtual item "Registration". Is it posible to manage it by some way? Thank you! George Link to comment Share on other sites More sharing options...
Recommended Posts