Page 2 of 5

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 3:52 pm
by sraj49
Thanks a lot. I have a small issue...When I login to the application through the Home page and when I log out I am not logged out of the main login. If I close the browser or click the back button, the user is still logged in and you have to click Log out twice to get back to the home page. Do you have any suggestion...Than you once again

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 5:05 pm
by iamwaggle
Hey sraj49!

I'm not experiencing the same problem that you are having. Do you need to upgrade your Joomla! system to the latest? I made some improvements to our little method however... Maybe this will help. I hope it does!

This is a compilation of work done by iamwaggle, sraj49, and Olaf:

~~~~Login Redirect Hack~~~~

1: create field for the url........For this you need to change the following codes:

a) admin/component/com_user/models/user.xml ...add this at the end....

Code: Select all

<param name="url" type="text" default="" label="Front-end Login Redirect" description="URL redirect for a Front-end login" />
<param name="adminurl" type="text" default="" label="Back-end Login Redirect" description="URL redirect for a Back-end login" />
b) admin/components/com_user/models/registered.xml...add this at the end...

Code: Select all

<param name="url" type="text" default="" label="Front-end Login Redirect" description="URL redirect for a Front-end login" />
<param name="adminurl" type="text" default="" label="Back-end Login Redirect" description="URL redirect for a Back-end login" />
2: After this go to components/com_user/controller.php...after line 146???

In the login function, change this:

Code: Select all

if(!JError::isError($error)){
		
// Redirect if the return url is not registration or login
if ( ! $return ) {
$return= 'index.php?option=com_user';
}
To this:

Code: Select all

if(!JError::isError($error))
{
$user =& JFactory::getUser();
$user->getParameters();
if (!$user->getParam('url') == ''){
$return = $user->getParam('url');
}

// Redirect if the return url is not registration or login
if ( ! $return ) {
$return = 'index.php?option=com_user';
}
3: /administrator/components/com_login/admin.login.php... after line 66???

In the login function, change this:

Code: Select all

if (!JError::isError($result)) {
$mainframe->redirect('index.php');
}
To this:

Code: Select all

$user =& JFactory::getUser();
$user->getParameters();
$return = $user->getParam('url');

if (!JError::isError($result) && ! $return) {
$mainframe->redirect('index.php');
}else if (!JError::isError($result)) {
$mainframe->redirect($return);
}

Now when you create a user using the User Manager, you can specify the Front-End and Back-end URLs. These can be edited at any time. When you make this change to a user's parameters, the login automatically redirects the user to the specific URL in the user profile.

Many thanks to Raj and Olaf for laying all the groundwork!
~iamwaggle

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 6:10 pm
by sraj49
Thanks a lot and youy are welcome..

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 6:14 pm
by cantorgreen
Raj - I added your code and it works when you create a new user (thank you!)

But when I go back in to EDIT the user, the URL field does not appear, so I can't change it, short of deleting and re-creating the user.

Any thoughts?
Thanks
Jason Green

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 6:17 pm
by sraj49
When I go to the User Manager and try to create a New USer I do not fonr the fields for Front-end and Backend URL's

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 6:25 pm
by iamwaggle
The database doesn't have the new parameters for your users until you re-save. In the database under "users" the params field needs to have:

url=
adminurl=

Try creating a new user. Try editing an existing user and coming back. If those things don't work, go into your database and add

url=
adminurl=

to the 'params' part of the user entry in the jos_users table

Best,
iamwaggle

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 6:27 pm
by iamwaggle
I do get the Front-end/Back-end fields with a new user creation. I don't know why you wouldn't unless you didn't change the XML docs correctly. Maybe a cache thing?

Re: User Specific Login Redirect

Posted: Tue Sep 01, 2009 10:35 pm
by sraj49
I can email you the screen shot of the new user creation page....My wmail id is: [email protected]

Re: User Specific Login Redirect

Posted: Tue Sep 08, 2009 2:02 pm
by snake3y3s
sorry if im hijacking the thread a little, but pulling out hair is beginning to make me go bald, Im trying to get a user specific thing going too, but its not working.

I have managed to make a "redirect to" based on users.

But i want to add a menu item that pops up specific to that logged in user.

I.E. we look at the menu on our main page and it has items on it like: home, work, clients, latest news, about us, contact us and client login.
now i want an item to appear after client login once a user has logged in (just like if u set a menu items access level to "registered user") BUT i want that item to link to a page SPECIFIC TO THE CURRENT LOGGED IN USER.

Any help/ideas?
All help greatly appreciated

Re: User Specific Login Redirect

Posted: Tue Sep 29, 2009 9:52 am
by rdimou
Hello to all, i am using Joomla! 1.5.13.
I need to have 2 pages show up as home page, one for public and one for users that are logged in/registered. I have created them both and i made one Public and the other Registered (Access Level ). When i am not log in i see the public page ok. But when i log in i see the article for registered users...but also below that article the public one also appears. What am i doing wrong?
can you help me?
thank you

Re: User Specific Login Redirect

Posted: Tue Sep 29, 2009 5:06 pm
by mic
1. use the lates Joomla version (actual 1.5.14)!
2. this is how Joomla works: each higher ACL level can see all his items AND what is for lower levels (same for frontend as well for the backend)

Re: User Specific Login Redirect

Posted: Fri Oct 09, 2009 5:30 pm
by jackv
I am so glad I found this. Thank you iamwaggle, sraj49, and Olaf! And it works great.

However, my user information details do not show the url field when I return after saving. I double checked all the edits/hack. I have even made sure the "url=" was added to the param in the database (per your suggestion iamwaggle). I don't believe it is a cache issue either.

Does anyone have another suggestion why I cannot see the url (except for the very first time a new user is created)?

Thanks all

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 4:41 am
by umccoy
How do I get my login page to bring up the specific page? Where do I "link" it?

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 9:33 am
by ooffick
Do you use the mod_login module?

Olaf

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 2:07 pm
by umccoy
Yes.

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 2:13 pm
by ooffick
Did you look into the module parameters? There is an option to add the login URL.

Olaf

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 2:26 pm
by umccoy
I guess I don't see that in the module. Also, when I try to login now, I'm getting this error message: "Fatal error: Unsupported operand types in /home1/stonewor/public_html/includes/router.php on line 148". Do you know what this means? I am extremely new to Joomly and website creation in general. Thanks in advance.

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 2:46 pm
by ooffick
My guess would be that the Menu Item which you selected doesn't exist, or that the article which linked from the menu item doesn't exists anymore.
capture#0140_2009-10-27.png
Olaf

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 2:50 pm
by umccoy
Why can't I see all of my articles under "Paremeters" in the mod_login, for "Login Redirection Page" and "Logout Redirection Page"? I'm trying to link these to a page that I created but they don't show up.

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 2:56 pm
by ooffick
You can only select a menu item? Do you will need to create a menu item first.

Olaf

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 3:01 pm
by umccoy
What if I don't want that page to show up in my menu on the frontend? (It's for certain level employees only.)

Re: User Specific Login Redirect

Posted: Tue Oct 27, 2009 3:21 pm
by ooffick
Try to create a new menu, a new menu item, and don't link the menu with a module.

Olaf

Re: User Specific Login Redirect

Posted: Thu Nov 05, 2009 11:20 pm
by greg218
ok.... i have used the trick described in the first page. I now upgraded to 1.5.14 now when i create a new user and input a redirect url.... it doesn't redirect.

For some reason, the user that i did this trick with before the upgrade do redirect.

Can someone post their controller.php code or file plus their other modification to their other files (user.xml etc) to get this redirect working.

Thanks
~G

Re: User Specific Login Redirect

Posted: Thu Nov 05, 2009 11:26 pm
by ooffick
Did you change all the files again?

Olaf

Re: User Specific Login Redirect

Posted: Fri Nov 06, 2009 12:26 am
by greg218
no i didnt change the files again....

oooo i looked into the 1.5.7 to 1.5.14 update file and i see that controller.php gets replaced.

So im assuming i just modify controller.php with any of the hacks above?

Thanks,
~Greg

Re: User Specific Login Redirect

Posted: Fri Nov 06, 2009 9:32 am
by ooffick
greg218 wrote:So im assuming i just modify controller.php with any of the hacks above?
Yes, or any other file which might have been replaced.

Olaf

Re: User Specific Login Redirect

Posted: Fri Nov 06, 2009 3:13 pm
by greg218
The joomla 1.5.14 controller.php looks different and i can't find

Code: Select all

if(!JError::isError($error)){
      
// Redirect if the return url is not registration or login
if ( ! $return ) {
$return= 'index.php?option=com_user';
}
this closest i found is

Code: Select all

if (!$user->bind($post))
		{
			$mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
			$mainframe->enqueueMessage($user->getError(), 'error');
			//$mainframe->redirect( 'index.php?option=com_users', $user->getError() );
			//return false;
			return $this->execute('edit');
		}
Can someone show how you would do this hack in joomla 1.5.14?

Thanks!
~Greg

Re: User Specific Login Redirect

Posted: Fri Nov 06, 2009 3:32 pm
by ooffick
Hi Greg,

Please make sure you are looking in the /components/com_users/controller.php and not in the /administrator/components/com_users/controller.php file.

Try to find this:

Code: Select all

		$credentials = array();
		$credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
		$credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);

		//preform the login action
		$error = $mainframe->login($credentials, $options);

		if(!JError::isError($error))
		{
			// Redirect if the return url is not registration or login
			if ( ! $return ) {
				$return	= 'index.php?option=com_user';
			}

			$mainframe->redirect( $return );
		}
and replace it with this:

Code: Select all

		$credentials = array();
		$credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
		$credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);

		//preform the login action
		$error = $mainframe->login($credentials, $options);

		if(!JError::isError($error))
		{
			$user =& JFactory::getUser();
			$user->getParameters();
			if (!$user->getParam('url') == ''){
				$return = $user->getParam('url');
			}

		
			// Redirect if the return url is not registration or login
			if ( ! $return ) {
				$return	= 'index.php?option=com_user';
			}

			$mainframe->redirect( $return );
		}
Olaf

Re: User Specific Login Redirect

Posted: Fri Nov 06, 2009 4:43 pm
by greg218
Thanks Olaf, It worked!

Re: User Specific Login Redirect

Posted: Wed Nov 11, 2009 9:22 pm
by joomwork
I wish to have some time, to create a generic plugin for this.
If anyone has already created one, please let me know.