Hello,
I’m trying to customize the current theme to look different based on the user security group.
I didn’t get it how to do so in a tpl file
any help please
I’m using version 7.11.15 on linux
Hello,
I’m trying to customize the current theme to look different based on the user security group.
I didn’t get it how to do so in a tpl file
any help please
I’m using version 7.11.15 on linux
@islamhanafi
You can use 3 logic_hooks together
and write the code like some this for changing user preference:
$user = new User();
$user->retrieve(<user_id>);
$user->->setPreference('subtheme', <theme name>, 0, 'global');
List of theme names:
thank you for you reply , can you refer me to any resource that helps as I can’t find anything helpful in the docs.
Hi, @islamhanafi
You can:
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(1, 'All hooks for user', 'custom/modules/Users/User_hook.php','User_hook', 'themesBySecurityGroup');
file: custom/modules/Users/User_hook.php
<?php
class User_hook {
function themesBySecurityGroup(&$bean, $event, $arguments) {
$sg=array();
$sg=$bean->get_linked_beans('securitygroups_users','SecurityGroup');
// place for analyse SecurityGroup and choosing <theme name>
$user->->setPreference('subtheme', <theme name>, 0, 'global');
}
}
$sg will have information about all security group which relate to the user.