Login Redirect for Groups

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?

View Replies: View Best Answer
jaushman replied on at Permalink Best Answer Reply
For those that have a similar need here is what I came up with for a solution. Inside of concrete/controllers/single_page/login.php there is a function that handles redirecting the user after login. This function, called chooseRedirect(), sits at line 211 in 5.7.3.

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:

namespace Application\Controller\SinglePage;
use Concrete\Core\Routing\RedirectResponse;
use Config;
use Loader;
use Page;
use Permissions;
use Session;
use User;
use UserInfo;
use View;
use Group;
use Concrete\Controller\SinglePage\Login as C5Login;
class Login extends C5Login
Ta2Ta2 replied on at Permalink Reply

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,.
neoroot replied on at Permalink Reply
Hi, take a different option :
I create Groups and Pages with the same name, personalize thats pages and finaly :
Same Place first Custom in this thread:
                $groups = $u->getUserGroups();
                foreach($groups as $groupID => $groupName) {
                        $group = \Concrete\Core\User\Group\Group::getByID($groupID);
                        if ($groupID > 3){
                                $RedirectByGroup = strtolower($group->getGroupName());
                        $rUrl = View::url("/".$RedirectByGroup."/");

and work fine in version 8.0.2