Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joomla 3 Login redirect - works in Login Module but does not working from component login view

I am working on Joomla 3.x I have a requirement to redirect to a new page after login. I know there is an option in Login Module under module manager, where in we can specify "login Redirection Page". This is working perfectly fine. it is redirecting to the place where i wish to.

However, the issue is - Once User creates a new account ( i have disabled the registration process, so no email links activation is required) user is presented with a Login view (not from module) from component - com_users. Once credentials are supplied, instead of redirecting to the desired page i set in module manager, it goes to profile page of com_users component. index.php/component/users/?view=profile

I need your suggestions to change this default behavior. Is there any place where i can set the redirection page for component com_users, similar to how we have for Login Module? Do I need to go for Joomla core file coding changes? Or Do i need to create Plugin which can fire after OnLoginUser event?

Expecting suggestion from you guys.

Thanks and regards, Gaurav Pandya

like image 951
Gary Avatar asked Aug 12 '14 09:08

Gary


2 Answers

In the menu item setup (menu item type -> login form) please check the options tab there is a field that you could set login redirect.

EDIT:

If your login is not connected to a menu please try make an override to: components/com_users/views/login/tmpl/default_login.php line 79:

<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
like image 189
emmanuel Avatar answered Nov 25 '22 20:11

emmanuel


Actually there is no need for a plugin or any template overrides.

If you're using a menu item to publish the login page then you simply need to add an absolute URL into the 'login redirect' field of the menu item itself (not the login module).

E.g. http://www.somesite.com/my-account and not /my-account

For some reason a relative url (/my-account) is counted as an external URL and is overriden in the controller which is why it's redirected to 'my-account/profile.

Hope this help somebody.

like image 30
Adam Rifat Avatar answered Nov 25 '22 21:11

Adam Rifat