prestashopprestashop-1.7prestashop-modules

Denying access to my custom module in prestashop


I created a custom module in prestashop but I don't know how to handle the access to this module. I didn't find any documentation about it. I know how to do it in symfony but not in prestashop. I just want to give access to my module to a group of users. Does someone know how to do it or have a link of documentation to help me?


Solution

  • You can check if logged user belongs to the certain group. My example below shows how to check user's default group in a controller. Based on that you can proceed with restricting your module.

    if ($this->context->customer->isLogged()) {
        $customerGroupId = $this->context->customer->id_default_group;
    }