Jump to content

Change Template Based on Client Group


JLHC

Recommended Posts

I created a hook to change the Template a client will see depending on which Client Group they are lumped into:-

<?php

function clientgroupTemplate($vars) {
	$client = Menu::context('client'); 
	$groupid = $client->groupid;
	if ($groupid == 1) {
        global $systpl;
        $systpl = 'MY_TEMPLATE';
        $GLOBALS['_SESSION']['Template'] = 'MY_TEMPLATE';
        $GLOBALS['CONFIG']['Template'] = 'MY_TEMPLATE';
	}
}
add_hook("ClientAreaPage", 1, "clientgroupTemplate");

However, the hook seem to only work on the second load, which means that the client will first see the default Template after login and only after a refresh or going to the second page will they see MY_TEMPLATE. 

I tried disabling all other hooks to rule out any conflicts. 

Is this due to caching like OPCache or is there a better way to write this hook? 

Thank you. 

Edited by JLHC
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated