Page 5 of 5

Re: User Specific Login Redirect

Posted: Tue Feb 15, 2011 1:26 am
by cwilson
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

Re: User Specific Login Redirect

Posted: Tue Feb 15, 2011 11:28 pm
by cwilson
Issue resolved, a case of read the full post and you'll save plenty time!

Cheers

Re: User Specific Login Redirect

Posted: Sat Feb 26, 2011 10:55 am
by DeDanan
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

Re: User Specific Login Redirect

Posted: Wed Apr 06, 2011 10:21 pm
by arlomaniac
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?

Re: User Specific Login Redirect

Posted: Mon Apr 25, 2011 7:14 pm
by cdougall
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 );

Re: User Specific Login Redirect

Posted: Tue Apr 26, 2011 1:58 pm
by arlomaniac
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

Re: User Specific Login Redirect

Posted: Wed May 04, 2011 11:42 am
by jamie297
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.

Re: User Specific Login Redirect

Posted: Wed May 04, 2011 1:38 pm
by arlomaniac
Charlene sent me some PM's with various suggested changes but none have so far worked - so any further ideas most welcome!

Re: User Specific Login Redirect

Posted: Wed May 04, 2011 2:09 pm
by jamie297
Has anyone had success with this hack? If they have it would be good to know what they did to get it to work.

Re: User Specific Login Redirect

Posted: Wed May 04, 2011 4:58 pm
by cdougall
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

Re: User Specific Login Redirect

Posted: Wed May 04, 2011 6:27 pm
by jamie297
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.