Page 1 of 1

Group dashboards

Posted: 2019-07-15 23:39
by jmcgov
Hi all,
I have seen two great posts on this forum showing JS changes to the homepage, which I could maybe repurpose for my needs, but I want to do something on backend, if possible.
In essence, I have 4 groups - guest, admin, supplier and client. I'd like to use the default dashboard/homepage for all groups, except the client and create a different dashboard for clients. Can I do this from PHP hooks files, or must I get down with JS? TIA James

Re: Group dashboards

Posted: 2019-07-16 06:29
by pbottcher
Hi,

you can use the in the hooks/__global.php to redirect to another page after successful login.

function login_ok($memberInfo, &$args){
## Check group and set RETURNPAGE
return RETURNPAGE;
}

Re: Group dashboards

Posted: 2019-07-16 07:33
by jmcgov
Yes, that should do it. Thanks pbotcher.

Re: Group dashboards

Posted: 2019-07-16 23:29
by jmcgov
Hi pböttcher
I did a slight variation on that, to remove the risk of the page being called directly through other links in the app (i.e. after login), which seems to work very well - I have included it, in case it proves useful to others.
Thanks once again for your steer. James

In hooks/header-extra.php
#DASHBOARD REDIRECT, START
if(strpos ( $_SERVER['PHP_SELF'] ,'index.php')){
$mi = getMemberInfo();
if(in_array($mi['group'], array('Club Member'))){
header("Location: /hooks/_dashboard.php");
exit();
}
}
#DASHBOARD REDIRECT, END