Jump to content

Edit History

Nishith Nesdiya

Nishith Nesdiya

Hi your code somthing look like this 

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class iModelAttachToClientGroup extends Module
{
    public function __construct()
        {
            $this->name = 'imodelattachtoclientgroup';
            $this->tab = 'others';
            $this->version = '1.0.1';
            $this->author = 'Quentin';
            $this->need_instance = 0;
            $this->ps_versions_compliancy = [
                'min' => '1.6',
                'max' => _PS_VERSION_
            ];
            $this->bootstrap = true;

            parent::__construct();

            $this->displayName = $this->l('iModel Attach user To Client Group');
            $this->description = $this->l('When a customer subscribe to our website, hes attached to the customer group Particuliers TTC, This module add him also into Client group.');

            $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

            if (!Configuration::get('MYMODULE_NAME')) {
                $this->warning = $this->l('No name provided');
            }
        } 
    
        public function install()
        {

            return parent::install() && $this->registerHook('actionCustomerAccountAdd');
        }

        public function uninstall()
        {
            return parent::uninstall();
        }

        public function hookActionCustomerAccountAdd($params){
			$customer = $params['newCustomer'];
			$customer->addGroups(array(3)); //3 id of customer group
        }
    
}

if add new hook in your module then uninstall and install module again
Thank you
 

Nishith Nesdiya

Nishith Nesdiya

Hi your code somthing look like this 

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class iModelAttachToClientGroup extends Module
{
    public function __construct()
        {
            $this->name = 'imodelattachtoclientgroup';
            $this->tab = 'others';
            $this->version = '1.0.1';
            $this->author = 'Quentin';
            $this->need_instance = 0;
            $this->ps_versions_compliancy = [
                'min' => '1.6',
                'max' => _PS_VERSION_
            ];
            $this->bootstrap = true;

            parent::__construct();

            $this->displayName = $this->l('iModel Attach user To Client Group');
            $this->description = $this->l('When a customer subscribe to our website, hes attached to the customer group Particuliers TTC, This module add him also into Client group.');

            $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

            if (!Configuration::get('MYMODULE_NAME')) {
                $this->warning = $this->l('No name provided');
            }
        } 
    
        public function install()
        {

            return parent::install() && $this->registerHook('actionCustomerAccountAdd');
        }

        public function uninstall()
        {
            return parent::uninstall();
        }

        public function hookActionCustomerAccountAdd(){
			$customer = $params['newCustomer'];
			$customer->addGroups(array(3)); //3 id of customer group
        }
    
}

if add new hook in your module then uninstall and install module again
Thank you
 

Nishith Nesdiya

Nishith Nesdiya

Hi your code somthing look like this 

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class iModelAttachToClientGroup extends Module
{
    public function __construct()
        {
            $this->name = 'imodelattachtoclientgroup';
            $this->tab = 'others';
            $this->version = '1.0.1';
            $this->author = 'Quentin';
            $this->need_instance = 0;
            $this->ps_versions_compliancy = [
                'min' => '1.6',
                'max' => _PS_VERSION_
            ];
            $this->bootstrap = true;

            parent::__construct();

            $this->displayName = $this->l('iModel Attach user To Client Group');
            $this->description = $this->l('When a customer subscribe to our website, hes attached to the customer group Particuliers TTC, This module add him also into Client group.');

            $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

            if (!Configuration::get('MYMODULE_NAME')) {
                $this->warning = $this->l('No name provided');
            }
        } 
    
        public function install()
        {

            return parent::install() && $this->registerHook('actionCustomerAccountAdd');
        }

        public function uninstall()
        {
            return parent::uninstall();
        }

        public function hookActionCustomerAccountAdd(){
			//get all customer here
			$customer = $params['newCustomer'];
			$customer->addGroups(array(3)); //3 id of customer group
        }
    
}

if add new hook in your module then uninstall and install module again
Thank you
 

×
×
  • Create New...