6

Not too much else to add to the question really, I'm trying to redirect a specific user group to a specific area after they log in to the administrator back-end, but I'm not sure if this is possible.

While somewhat of a separate goal, I also want to hide the admin menu.

4
  • Have you tried looking on the Joomla Extensions Directory? Maybe this might help: extensions.joomla.org/profile/extension/access-a-security/…
    – Lodder
    Apr 15, 2015 at 14:42
  • Preferably the solution would be free, at least at all if it's possible. I've been looking in various places including many Google searches.
    – Merlin
    Apr 15, 2015 at 14:44
  • Lodder, i was already create (and installed of course) a plugin (named 'RedireccionarAdministrativo'), exactly as you said, but it doesn't work. First of all, the system respond: "Call to undefined method plgAuthenticationRedireccionarAdministrativo::onUserAuthenticate()" after login. Secon of all, i'v changed the name of the method to "onUserAuthenticate", runs, but do not redirect. Can you help me, please? Thanks a lot.
    – BENKENOBI
    Sep 25, 2017 at 1:18
  • @BENKENOBI - Please create a new question so other users can see it aswell. Thank you
    – Lodder
    Apr 18, 2019 at 9:24

3 Answers 3

10

You could create a small plugin to perform the redirect. Here's something I've quickly mocked up:

class plgSystemMYPLUGIN extends JPlugin
{

    public function onUserAfterLogin()
    {
        $app = JFactory::getApplication();

        if ($app->isAdmin()) 
        {
            $user   = JFactory::getUser();
            $groups = $user->get('groups');

            $groups_to_redirect = array('13', '10');

            if (in_array($groups[0], $groups_to_redirect))
            {
                $url = JRoute::_('index.php?option=com_hellowworld');
                $app->redirect($url);
            }           
        }
    }

}

I've used 10 and 13 as example user group ID's, so you would have to change them to whatever suits your needs.

Please also note I haven't tested this, but hope it points you in the right direction

1
  • Works great! Just a small addition, a user can belong to multiple groups. Moreover, the group array is indexed by key (Joomla 3.8+). Therefore, this would work better: if ( !empty(array_intersect($groups, $groups_to_redirect)) )
    – Andreas
    Apr 18, 2019 at 7:03
1

How about that extension? I'd used it before when i needed to redirect users to specified direction :

http://extensions.joomla.org/extensions/extension/access-a-security/site-access/redirect-on-login

1
  • 1
    This is an extremely big extension just to perform a simple redirect on admin login. Have you not found any simple and small alternatives?
    – Lodder
    Apr 15, 2015 at 15:05
0

Its Just short cut method in 3.x

Open Path in Joomla plugins\authentication\cookie\cookie.php

In function onUserAfterLogin($options),

        $user   = JFactory::getUser();
        $groups = $user->get('groups');

            if(in_array(10, $groups)) 
            {
             $url = JRoute::_('index.php?option=com_students');
             $this->app->redirect($url);
            } 
2
  • Changing the core files of any updateable system is NOT recommended.
    – Farahmand
    Jul 15, 2016 at 7:17
  • Its just work around method. Invoke function call. Jul 26, 2016 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.