Adam Plšek Adam Plšek -4 years ago 178
PHP Question

prestashop 1.6 - check if user is in group

in PS 1.6 I am trying to check if user is in group with id 6 using this:

controller:

'hisGroup' => ($this->context->customer->logged AND (Customer::getDefaultGroupId((int)$this->context->customer->id) == 6) ? true : false)


tpl:

{if $hisGroup}...{/if}


although it's not working. Do you have any idea why is that?

Answer Source

With this code you are checked the customer´s default group. To checked if customer is in a group independently of default group try this

'inCustomerGroup' => in_array(4, Customer::getGroupsStatic($this->context->cart->id_customer)) ? true : false,
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download