Login Redirect for Groups
Permalink
Is it possible within 5.7 to redirect users after a successful login based on their group membership? For the current website I'm working on there are 2 different user groups which have access to two distinct areas of the website. Each group has their own landing page that I would like to redirect users to.
I've attempted to dissect the login.php single page controller but am having a hard time understanding where/how to insert a check for the user's group in that process. Any ideas or previous success?
I've attempted to dissect the login.php single page controller but am having a hard time understanding where/how to insert a check for the user's group in that process. Any ideas or previous success?
Hi,
I restricted files download to registered users only. For that, if you click on file to download and not logged in, you will redirected to login page. Once login the website redirects you to homepage.
I want the website to start downloading right after successful login.
any help?
thanks in advance,.
I restricted files download to registered users only. For that, if you click on file to download and not logged in, you will redirected to login page. Once login the website redirects you to homepage.
I want the website to start downloading right after successful login.
any help?
thanks in advance,.
Hi, take a different option :
I create Groups and Pages with the same name, personalize thats pages and finaly :
/concrete/controllers/single_page/login.php
Same Place first Custom in this thread:
and work fine in version 8.0.2
I create Groups and Pages with the same name, personalize thats pages and finaly :
/concrete/controllers/single_page/login.php
Same Place first Custom in this thread:
######## $RedirectByGroup=""; $groups = $u->getUserGroups(); foreach($groups as $groupID => $groupName) { $group = \Concrete\Core\User\Group\Group::getByID($groupID); if ($groupID > 3){ $RedirectByGroup = strtolower($group->getGroupName()); } } if($RedirectByGroup!=""){ $rUrl = View::url("/".$RedirectByGroup."/"); break; } ########
and work fine in version 8.0.2
Since we don't want to modify this function in the core files I created a new file at application/controllers/single_page/login.php. By extending the core Login class in this file I'm able to safely modify just the function I'm interested in.
In my case I added a few lines in front of all other redirects that will check if the now logged-in user belongs to a particular group and, if so, will set the redirect URL variable ($rUrl) to the appropriate URL. If the user doesn't belong to either of those groups then the core redirect method continues as normal.
Here's what my application/controllers/single_page/login.php file looks like now: