Search code examples
http-redirectjoomlaauthentication

Joomla 3 redirect after wrong login try


Iam using the login module of Joomla. Login and Logout redirects to the pages which are set in the modul settings.

My problem is the status, where a user tries to login with wrong user credentials. In this case, the user will be redirected to component/users/?view=login page. In my case, this page is not in use and also not designed like the rest of the pages. Therefore I would like to redirect the user, after a wrong login, to the previous page.

Does anybody have a clue, how to solve that?

thx


Solution

  • You will need to modify users controller. But to keep it "update proof" you cannot modify the core code, thats why we will make an override:

    1. Go to the components/com_users/controllers/ and duplicate a file called user.php, you can call a new file user2.php
    2. Open user2.php file and rename controller class to UsersControllerUser2
    3. Create a template override of your login module (to make it update proof also), create a templates/YOUR_TEMPLATE/html/mod_login folder and copy modules/mod_login/tmpl/default.php file there.
    4. Open file created in step 3 and change login module task from <input type="hidden" name="task" value="user.login" /> to <input type="hidden" name="task" value="user2.login" />
    5. Open user2.php file once again, and modify this part of code (around lines 77-82):

    $app->redirect(JRoute::_('index.php?option=com_users&view=login', false));

    Change $app->redirect route to whatever you want :)