Search code examples
prestashopaccountmanualactivationmultistore

multi store, manual activation account with prestashop


I use multi-store option with prestashop. I would like to pass customers in the second store to manual activation after registration.

Actually I set $customer->active = 0; in authentication.php.

all registration customer in both websites are inactive after registration.

Is there a way to set $customer->active = 0; just for one website.

I think to get shop_id but I don't know how to develop my idea.


Solution

  • In Prestashop 1.6 :

    You can get the id_shop with the Context object.

    So, I think you can do something like this :

    If you know the id_shop (suppose the id_shop = 1)

    if (Context::getContext()->shop->id == 1) {
        $customer->active = 0;
    } else {
        $customer->active = 1;
    }
    

    Hope it helps.

    EDIT

    Updated answer to get the id_shop from context because the Customer object doesn't handle it until it's added.

    RE-EDIT

    In the Customer class (/classes/Customer.php) customize the add() function.

    Add this line around the line 212 (after the "last_passwd_gen" declaration) :

    $this->active = ($this->id_shop == 3) ? false : true;
    

    But the best solution for you is to create an override of the function.