User Specific Login Redirect

Your code modifications and patches you want to share with others.
cwilson
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jul 07, 2010 1:56 pm

Re: User Specific Login Redirect

Postby cwilson » Tue Feb 15, 2011 1:26 am

My Joomla version 1.5.22

Yoong Kim's (kiminox) modifications in his post above (Tue Jul 13, 2010 2:45) work like a charm redirecting users logging in through the back-end. However he doesn't say which files need modifying to achieve this for users logging in through the front-end. Any pointers gratefully received.

Cheers,

Carl

cwilson
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jul 07, 2010 1:56 pm

Re: User Specific Login Redirect

Postby cwilson » Tue Feb 15, 2011 11:28 pm

Issue resolved, a case of read the full post and you'll save plenty time!

Cheers

DeDanan
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Feb 26, 2011 9:47 am

Re: User Specific Login Redirect

Postby DeDanan » Sat Feb 26, 2011 10:55 am

Hi All,

Has no one got a working extension not a hack for this for 1.5? In the JED two are listed that seem to do User direct on login to user specific page but one does not work and the other has a broken link to the download! I do not want to change the base code, just buy and install a working extension. Any suggestions?

Regards

DeDanan

arlomaniac
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Aug 20, 2009 12:00 pm

Re: User Specific Login Redirect

Postby arlomaniac » Wed Apr 06, 2011 10:21 pm

Hi Guys, had this working fine when on 1.5.17 but had to upgrade to 1.5.23 for another component and now it just falls flat using kiminox's hack even though the admin.login.php looks similar. Has anyone sussed this out or come up with an alternative?

cdougall
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Apr 25, 2011 6:47 pm
Contact:

Re: User Specific Login Redirect

Postby cdougall » Mon Apr 25, 2011 7:14 pm

custom redirection after sign in

For Joomla 1.5.X, here is a simple hack to redirect users to a different article page after sign in.

User Redirection File
Create a text file that list all user Names with the redirected article ID.
For example,
UserName1;ArticleID1
UserName2;ArticleID2
UserName3;ArticleID3
……
Note: I use a semi-colon to separate the user ID from the article ID.
Save the file on your server.

Update controller.php file
Go to [joomla site]/components/com_user directory.
Make a back up copy of controller.php.
Open controller.php.


In the function login() add the following code above the following line. (This should be line 163).
$mainframe->redirect( $return );

New CODE

Code: Select all

$login_user = JRequest::getVar('username', '', 'method', 'username');
$userpage = [b]0[/b];   //Change the 0 to a Default Article ID.
$file = file_get_contents("URL of user redirection file");
$fileline = explode("\n", $file);
for ($i=0;$i<count($fileline);$i++)
{
     $userline = explode(";",$fileline[$i]); //separated by Semi Colon
     if ( $userline[0] == $login_user ) {
          $userpage = $userline[1];  //Get the Article ID      
     }
}
           $userpage = 'http://[b]joomla site[/b]/index.php?option=com_content&view=article&id='.$userpage;   


Now change the line, $mainframe->redirect( $return ); to

Code: Select all

$mainframe->redirect( $userpage );
Last edited by cdougall on Tue Apr 26, 2011 2:39 pm, edited 2 times in total.
Charlene N. Dougall
President, Mapp Technology

arlomaniac
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Aug 20, 2009 12:00 pm

Re: User Specific Login Redirect

Postby arlomaniac » Tue Apr 26, 2011 1:58 pm

Thanks Charlene but I'm obviously missing something here.

I've got a redirect file called redirect.txt which lists:

UserID63;ArticleID15
UserID64;ArticleID16
UserID71;ArticleID17
UserID72;ArticleID18
UserID73;ArticleID19
UserID74;ArticleID20

and tried various versions e.g. ID63;ID15 and 63;15

The code that I've entered into crontroller.php is:

Code: Select all

         $mainframe->redirect( $userpage );
      $login_user = JRequest::getVar('username', '', 'method', 'username');
$userpage = 3;   //Change the 0 to a Default Article ID.
$file = file_get_contents("http://rememberphotos.co.uk/redirect.txt");
$fileline = explode("\n", $file);
for ($i=0;$i<count($fileline);$i++)
{
     $userline = explode(";",$fileline[$i]); //separated by Semi Colon
     if ( $userline[0] == $login_user ) {
          $userpage = $userline[1];  //Get the Article ID     
     }
}
           $userpage = 'http://rememberphotos.co.uk/index.php?option=com_content&view=article&id='.$userpage;


Which includes a semi-colon at the end of the replaced line 163 that seemed to be missing (webpage just crashed without it), but when clients log in they just stay on the default article (3).

Anything obvious that I'm missing?

Cheers Bill

jamie297
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 04, 2011 10:50 am

Re: User Specific Login Redirect

Postby jamie297 » Wed May 04, 2011 11:42 am

Charlene, this looks like a promising solution if we can get it to work, but like Bill above I am having the same problem.

I created the text file and structured it like Bill did above e.g. UserID72;ArtcleID65

I have followed the instructions word for word but when I log in it does not redirect. Like Bill has experienced, it simply takes my users to my default page (43).

My code is:

Code: Select all

$login_user = JRequest::getVar('username', '', 'method', 'username');
$userpage = 43;   //Change the 0 to a Default Article ID.
$file = file_get_contents("http://www.siddoc.co.uk/userredirection.txt");
$fileline = explode("\n", $file);
for ($i=0;$i<count($fileline);$i++)
{
     $userline = explode(";",$fileline[$i]); //separated by Semi Colon
     if ( $userline[0] == $login_user ) {
          $userpage = $userline[1];  //Get the Article ID     
     }
}
           $userpage = 'http://www.siddoc.co.uk/index.php?option=com_content&view=article&id='.$userpage;   

         $mainframe->redirect( $userpage );

Also I have noticed Bill has put the code below

Code: Select all

$mainframe->redirect( $userpage );
when you stated it needs to be above, which I have done.

Many Thanks.

arlomaniac
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Aug 20, 2009 12:00 pm

Re: User Specific Login Redirect

Postby arlomaniac » Wed May 04, 2011 1:38 pm

Charlene sent me some PM's with various suggested changes but none have so far worked - so any further ideas most welcome!

jamie297
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 04, 2011 10:50 am

Re: User Specific Login Redirect

Postby jamie297 » Wed May 04, 2011 2:09 pm

Has anyone had success with this hack? If they have it would be good to know what they did to get it to work.

cdougall
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Apr 25, 2011 6:47 pm
Contact:

Re: User Specific Login Redirect

Postby cdougall » Wed May 04, 2011 4:58 pm

There is possibility that the text file is not being read correctly.

Here is a test to try.
Before this line
$userpage = 'http://joomla site/index.php?option=com_content&view=article&id='.$userpage;
add this line
if ( $login_user == 'Enter User Name to Test') {
$userpage = Article ID; //Change to Article ID associated with the User you are testing
}


Good Luck
Charlene
Charlene N. Dougall
President, Mapp Technology

jamie297
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 04, 2011 10:50 am

Re: User Specific Login Redirect

Postby jamie297 » Wed May 04, 2011 6:27 pm

Hi Charlene, thanks for the reply, however I got it to work before your reply!

Turns out that I wasn't structuring the redirect .txt file properly!

As soon as I structured it like this it worked fine:

jcole;ArtcleID65
rdell;ArticleID66
shadfield;ArticleID67

(before I was writing it like this: UserID72;ArtcleID65)

Many thanks for providing a working solution to specific user redirect.


Return to “Core Hacks and Patches”

Who is online

Users browsing this forum: No registered users and 2 guests