Joomla, custom redirection after sign in

When a user signs in in Joomla, he is automatically redirected at homepage.

This article explains you how to add a hack in Joomla 1.5, to redirect the user to the page of your choice after he signed in. It may be useful, especially if you want the user to do a specific action (e.g. : to post an article, a picture, subscribe to your services, etc.). From back-end, you may specify a Joomla! page for redirection, but no custom URL.

I used Joomla 1.5.8 for this example, but it should be the same pattern for every other J1.5.x version.

Open this file :


[votre site]/components/com_user/controller.php

Look for this code line, that should be located at line 163, inside the login() function :

login() :

$mainframe->redirect( $return );

All you have to do is to replace $return by the URL where you want users to be redirected. For instance :

$mainframe->redirect( “http://www.guylabbe.ca” );

Ce message est également disponible en : French

10 thoughts on “Joomla, custom redirection after sign in

  1. i was happy to find this post…but this does not work when i tried it. I am trying to have user redirect to my custom page and not home page after they register.
    Let me know if you have any suggestions.

    • Hi, Thanks for you interest! Just type the URL of your custom page instead of current (home) URL, but I guest you may have already tried this :) If it doesn’t work, would you post here your code please so we can have a look at it

  2. I tried this but it didn’t work, maybe because i was using a login page instead of login module on the side.

    I solved it by editing index.php – the idea is to detect that it’s a login page and add a base64_encode return url on the current URL. It might be a bit dodgy but it works for me.

    //if the page is login page – find out ur query string by ‘echo’ it
    if($_SERVER['QUERY_STRING'] == ‘option=com_user&view=login&Itemid=21′){

    //this is where you want to redirect user
    $returnURL = base64_encode(‘index.php/component/ezrealty/?controller=properties&task=add’);

    //using js redirect to add your default ‘return url’
    echo ““;
    }

    If you have the same problem, hopefully it would help :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>