User Specific Login Redirect
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
ok, and what happends when you login with the correct password?
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 15
- Joined: Wed May 19, 2010 11:48 pm
Re: User Specific Login Redirect
If you look at this link this will show you what happens when you logged in (I have attached a photo in the content so that you can see)
http://www.ips-photography.co.uk/index. ... e&Itemid=1
http://www.ips-photography.co.uk/index. ... e&Itemid=1
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
ok, so that means that the parameter is not working:
Try to hard code a URL to see if the other code is working.
Olaf
Code: Select all
$return = $user->getParam('url');
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 15
- Joined: Wed May 19, 2010 11:48 pm
Re: User Specific Login Redirect
tried to hard code and it didn't make any difference. I have put it back now to how it was: -
$return = $user->getParam('url');
$return = $user->getParam('url');
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
well, then you probably changing the wrong file.
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 15
- Joined: Wed May 19, 2010 11:48 pm
Re: User Specific Login Redirect
I have just had a quick mess around and changed this bit: -
// Redirect if the return url is not registration or login
if ( ! $return ) {
$return = 'index.php?option=com_user';
}
to
// Redirect if the return url is not registration or login
if ( ! $return ) {
$return = 'http://www.ips-photography.co.uk/index. ... 2&Itemid=3';
and it worked
// Redirect if the return url is not registration or login
if ( ! $return ) {
$return = 'index.php?option=com_user';
}
to
// Redirect if the return url is not registration or login
if ( ! $return ) {
$return = 'http://www.ips-photography.co.uk/index. ... 2&Itemid=3';
and it worked
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
I just tried this myself and that works as well:
So if your url parameter is not working then it is probably not saved in the user object.
Olaf
Code: Select all
if(!JError::isError($error))
{
$return = "index.php?test";
// Redirect if the return url is not registration or login
if ( ! $return ) {
$return = 'index.php?option=com_user';
}
$mainframe->redirect( $return );
}
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 15
- Joined: Wed May 19, 2010 11:48 pm
Re: User Specific Login Redirect
This is what is in the user.xml (I am hoping this is what you meant): -
<form>
<params>
<param name="admin_language" type="languages" client="administrator" default="" label="Back-end Language" description="paramAdminLanguage" />
<param name="language" type="languages" client="site" default="" label="Front-end Language" description="paramLanguage" />
<param name="editor" type="editors" default="" label="User Editor" description="WYSIWYG Editor for this User" />
<param name="helpsite" type="helpsites" default="" label="Help Site" description="Help Site for this User" />
<param name="timezone" type="timezones" default="" label="Time Zone" description="Time Zone for this User" />
<param name="login" type="menuitem" default="" label="Login Redirection URL" description="What page will the login redirect to after user login, if let blank will load module default" />
<param name="logout" type="menuitem" default="" label="Logout Redirection URL" description="What page will the login redirect to after user logout, if let blank will load module default" />
</params>
</form>
<form>
<params>
<param name="admin_language" type="languages" client="administrator" default="" label="Back-end Language" description="paramAdminLanguage" />
<param name="language" type="languages" client="site" default="" label="Front-end Language" description="paramLanguage" />
<param name="editor" type="editors" default="" label="User Editor" description="WYSIWYG Editor for this User" />
<param name="helpsite" type="helpsites" default="" label="Help Site" description="Help Site for this User" />
<param name="timezone" type="timezones" default="" label="Time Zone" description="Time Zone for this User" />
<param name="login" type="menuitem" default="" label="Login Redirection URL" description="What page will the login redirect to after user login, if let blank will load module default" />
<param name="logout" type="menuitem" default="" label="Logout Redirection URL" description="What page will the login redirect to after user logout, if let blank will load module default" />
</params>
</form>
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
ok, I so you added two parameters login and logout, correct?
However, in your controller you are trying to access the parameter url, which doesn't exist.
Try to find this and replace it with this
Olaf
However, in your controller you are trying to access the parameter url, which doesn't exist.
Try to find this
Code: Select all
getParam('url');
Code: Select all
getParam('login');
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 15
- Joined: Wed May 19, 2010 11:48 pm
Re: User Specific Login Redirect
Great stuff, its all working - many thanks for all your help on this, very appreciated.
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Sep 05, 2005 1:26 am
Re: User Specific Login Redirect
I didn't see this answered before.. So apologies if it was. I am running Joomla 1.5.18.
When a user registers on my site, I need them to enter some additional information. When they log into the site for the 1st time (or until such time as they have entered in the information) I want to redirect users one page (a form I have setup which prompts to collect additional user information). If they already entered the necessary information, I want them to be redirected to a different page upon subsequent logins.
Someone wrote me this piece of code that is supposed to check that the user entered the additional information, but I am not sure where I would put it to get the results I described above.
I am using the standard Login Module.
Thanks in advance.
Evan
When a user registers on my site, I need them to enter some additional information. When they log into the site for the 1st time (or until such time as they have entered in the information) I want to redirect users one page (a form I have setup which prompts to collect additional user information). If they already entered the necessary information, I want them to be redirected to a different page upon subsequent logins.
Someone wrote me this piece of code that is supposed to check that the user entered the additional information, but I am not sure where I would put it to get the results I described above.
I am using the standard Login Module.
Code: Select all
<?php
// check if in noc_users table
$database = &JFactory::getDBO();
$USER =& JFactory::getUser();
$uid = $USER->id;
$qrstring = "SELECT * FROM #__noc_users WHERE user_id = '$uid' ";
$database->setQuery($qrstring);
$dberr="";
if (!$database->query()) {
$dberr = $database->getErrorMsg();
echo($dberr."<br>");
echo($func." : ".$uid."-- ".time());
}
$rows = $database->loadObjectList();
$num_rows = count($rows);
if($num_rows == 0){
$host = $_SERVER["HTTP_HOST"];
header("Location: /index.php?option=com_nocform&func=doform");
}
?>
Evan
-
- Joomla! Fledgling
- Posts: 2
- Joined: Sat Oct 04, 2008 8:20 pm
Re: User Specific Login Redirect for JOOMLA 1.5.17
Hi,
For those who faced to the same problem, here is the process for the Joomla! 1.5.17.
1) open the XML file: administrator/components/com_users/models/user.xml
and the parameters that will be available for EACH user:
2) Open the PHP file:administrator/components/com_login/admin.login.php
and modify the line number 66 (well, around 66 of course!)
3) if you want to configure a special url redirect for an user, go to the control panel, open the user manager. In the "Parameters" tab, you should see 2 ne parameters:
Front-end Login Redirect
Back-end Login Redirect
Fill the fields and save the user.
Yoong
PS: you can do the same thing for the frontend login.
For those who faced to the same problem, here is the process for the Joomla! 1.5.17.
1) open the XML file: administrator/components/com_users/models/user.xml
and the parameters that will be available for EACH user:
Code: Select all
<!-- Yoong Kim 13/07/2010: add custom redirection after logged -->
<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" />
and modify the line number 66 (well, around 66 of course!)
Code: Select all
// Yoong Kim 13/07/2010: add custom redirect
$user =& JFactory::getUser();
$user->getParameters();
$returnAdminUrl = $user->getParam('adminurl');
if (!JError::isError($result)) {
// Yoong Kim 13/07/2010: add custom redirect
$return = 'index.php';
if ( !empty($returnAdminUrl) ) {
$return = $returnAdminUrl;
}
$mainframe->redirect($return);
}
Front-end Login Redirect
Back-end Login Redirect
Fill the fields and save the user.
Yoong
PS: you can do the same thing for the frontend login.
-
- Joomla! Fledgling
- Posts: 1
- Joined: Sun Aug 15, 2010 3:35 pm
Re: User Specific Login Redirect
This is absolutely amazing!! IT WORKS WITH COMMUNITY BUILDER with no additional codes!Qwomg wrote:Instructions for Joomla 1.5(.8 ) (with credit @barnett):
1. On the files
administrator/components/com_users/models/author.xml
administrator/components/com_users/models/registered.xml
administrator/components/com_users/models/user.xml
right before </params> add the following lines:2. Go to components/com_user/controller.php and after line ~134:Code: Select all
<param name="login" type="menuitem" default="" label="Login Redirection URL" description="What page will the login redirect to after user login, if let blank will load module default" /> <param name="logout" type="menuitem" default="" label="Logout Redirection URL" description="What page will the login redirect to after user logout, if let blank will load module default" />
add the following code:Code: Select all
$error = $mainframe->login($credentials, $options);
3. One the same file (controller.php) after line ~160:Code: Select all
$user =& JFactory::getUser(); $menu =& JSite::getMenu(); $userRedirect = $user->getParam('login'); if ($userRedirect) { $item = $menu->getItem($userRedirect); $url = $item->link; $return = $url; }
add:Code: Select all
function logout() { global $mainframe;
then a couple of lines later, afterCode: Select all
$user =& JFactory::getUser(); $menu =& JSite::getMenu(); $userRedirect = $user->getParam('logout'); if ($userRedirect) { $item = $menu->getItem($userRedirect); $url = $item->link; $return = $url; }
add:Code: Select all
if(!JError::isError($error)) {
one line before the next if.Code: Select all
if (!$return)
4. Set up individual user login and logout redirections from the user manager.
Thanks so much!!
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Oct 24, 2005 1:35 pm
Re: User Specific Login Redirect
I succeeded in getting the redirect to work. So after a login the user ends up on his personal page. But now I would like a button to get him (or her) back to that page after he (os she) has been browsing the site. From what I read in this topic this seems to be a wish more people have. Anyone succeeded in getting this button to work?
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
Why don't you create a module, generate the URL and output that as a link or button?
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Oct 24, 2005 1:35 pm
Re: User Specific Login Redirect
Olaf
simply because I don't know how ;-) If I would, I wouldn't have posted my question in the first place don't you think.
;-)
Good to know this topic is still alive.
simply because I don't know how ;-) If I would, I wouldn't have posted my question in the first place don't you think.
;-)
Good to know this topic is still alive.
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
You would will find a Tutorial on how to create a module here: http://docs.joomla.org/How_to_create_a_module
And instead of outputing Hello World, you will need to output the link , similar to the redirect you have done earlier.
You will need to change YOUR_CLICK_HERE_TEXT and YOUR_PARAMETER to whatever you need.
Olaf
And instead of outputing Hello World, you will need to output the link , similar to the redirect you have done earlier.
Code: Select all
<?php
$user =& JFactory::getUser();
$userRedirect = $user->getParam('YOUR_PARAMETER');
?>
<a href="<?php echo $userRedirect; ?>">YOUR_CLICK_HERE_TEXT</a>
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Oct 24, 2005 1:35 pm
Re: User Specific Login Redirect
Thanks Olaf
After I've finished trying to get Pages and Items fix my problem I'll have a look at your solution.
My problem is in fact quit simple. I need different users to have different access to documents. And NO DOCMAN is not a solution for me cause in Docman it is not possible to multi-select access-groups on a document. So every time users/groups/access changes I have to rearrange.
The idea is to get users (belonging to a certain group) to a page with weblinks to documents and to use the button to let them return to this page.
So far; http://www.pages-and-items.com/index.php looks promissing to me!
Thanks again!
After I've finished trying to get Pages and Items fix my problem I'll have a look at your solution.
My problem is in fact quit simple. I need different users to have different access to documents. And NO DOCMAN is not a solution for me cause in Docman it is not possible to multi-select access-groups on a document. So every time users/groups/access changes I have to rearrange.
The idea is to get users (belonging to a certain group) to a page with weblinks to documents and to use the button to let them return to this page.
So far; http://www.pages-and-items.com/index.php looks promissing to me!
Thanks again!
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Oct 24, 2005 1:35 pm
Re: User Specific Login Redirect
Olaf
If I try rour example my test.php says;
Fatal error: Class 'JFactory' not found in /home/*****/domains/******/public_html/test.php on line 2
*** = censored ;-)
If I try rour example my test.php says;
Fatal error: Class 'JFactory' not found in /home/*****/domains/******/public_html/test.php on line 2
*** = censored ;-)
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
yes, JFactory is a joomla class, so you will not be able to run it outside the joomla framework.
That's why I suggested to create a module with a link to the tutorial:
http://docs.joomla.org/How_to_create_a_module
Please note that you have to install the module in order to use the joomla framework.
Olaf
That's why I suggested to create a module with a link to the tutorial:
http://docs.joomla.org/How_to_create_a_module
Please note that you have to install the module in order to use the joomla framework.
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Oct 24, 2005 1:35 pm
Re: User Specific Login Redirect
I've tried to create a module for golfscores on my website but got stuck. Since this is a whole new subject I'll leave that for what it is. Pages and Items does the trick for me. I've created several pages and can redirect users to the pages they need to see together with a nice link in a menu. Thank you all for your time and effort!
-
- Joomla! Apprentice
- Posts: 32
- Joined: Wed Sep 08, 2010 5:50 pm
- Location: Staffordshire, UK
Re: User Specific Login Redirect
hi folks,
Will this help me accomplish what I am trying to do in http://forum.joomla.org/viewtopic.php?f=470&t=554894??
Will this help me accomplish what I am trying to do in http://forum.joomla.org/viewtopic.php?f=470&t=554894??
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Oct 24, 2005 1:35 pm
Re: User Specific Login Redirect
I've you create a "special" page for each and everyone of your users you are correct. Simply redirect to the special page.
-
- Joomla! Fledgling
- Posts: 2
- Joined: Fri Jul 11, 2008 2:42 pm
Re: User Specific Login Redirect for JOOMLA 1.5.17
HOW?PS: you can do the same thing for the frontend login.
-
- Joomla! Apprentice
- Posts: 6
- Joined: Mon Aug 02, 2010 7:01 am
Re: User Specific Login Redirect
Hi
I'm running 1.5.18, but I can't seem to make this work. When I make the changes to admin.login.php, attempts to login just loops back to the login page. Following is the code for my admin.login.php
I'm running 1.5.18, but I can't seem to make this work. When I make the changes to admin.login.php, attempts to login just loops back to the login page. Following is the code for my admin.login.php
I'm new to this so be gentle with me. I'm wondering if it might be that I need to add the URL redirects for the login I'm using somewhere first, but I don't know where to do this.<?php
/**
* @version $Id: admin.login.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @subpackage Joomla.Extensions
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
switch ( JRequest::getCmd('task'))
{
case 'login' :
LoginController::login();
break;
case 'logout' :
LoginController::logout();
break;
default :
LoginController::display();
break;
}
/**
* Static class to hold controller functions for the Login component
*
* @static
* @package Joomla
* @subpackage Login
* @since 1.5
*/
class LoginController
{
function display()
{
jimport('joomla.application.module.helper');
$module = & JModuleHelper::getModule('mod_login');
$module = JModuleHelper::renderModule($module, array('style' => 'rounded', 'id' => 'section-box'));
echo $module;
}
function login()
{
global $mainframe;
// Check for request forgeries
JRequest::checkToken('request') or jexit( 'Invalid Token' );
$credentials = array();
$credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
$credentials['password'] = JRequest::getVar('passwd', '', 'post', 'string', JREQUEST_ALLOWRAW);
// Yoong Kim 13/07/2010: add custom redirect
$user =& JFactory::getUser();
$user->getParameters();
$returnAdminUrl = $user->getParam('adminurl');
if (!JError::isError($result)) {
// Yoong Kim 13/07/2010: add custom redirect
$return = 'index.php';
if ( !empty($returnAdminUrl) ) {
$return = $returnAdminUrl;
}
$mainframe->redirect($return);
}
if (!JError::isError($result)) {
$mainframe->redirect('index.php');
}
LoginController::display();
}
function logout()
{
global $mainframe;
$result = $mainframe->logout();
if (!JError::isError($result)) {
$mainframe->redirect('index.php?option=com_login');
}
LoginController::display();
}
}
-
- Joomla! Apprentice
- Posts: 9
- Joined: Thu Jul 22, 2010 4:48 am
Re: User Specific Login Redirect
hai i am using joomla 1.5.20 i dont see the codes in \administrator\components\com_users.So pls specify the code for joomla1.5.20 for different login redirect
Last edited by ooffick on Thu Jan 13, 2011 12:17 pm, edited 1 time in total.
Reason: Mod Note: Duplicate post deleted, please do not post your question multiple times. Please read the forum rules for details.
Reason: Mod Note: Duplicate post deleted, please do not post your question multiple times. Please read the forum rules for details.
- ooffick
- Joomla! Master
- Posts: 11615
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: User Specific Login Redirect
Which "codes" can you not see, did you read all the posts in this topic?
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Fledgling
- Posts: 1
- Joined: Tue Jan 25, 2011 10:48 pm
Re: User Specific Login Redirect
Can someone please post the complete instructions for this for Joomla! 1.5.22. I have tried several versions of the instructions in this thread, and none is working yet. I'm assuming it is because my version is newer than older sets of instructions.
Thank you in advance!
Thank you in advance!
-
- Joomla! Intern
- Posts: 59
- Joined: Tue Mar 17, 2009 11:17 pm
Re: User Specific Login Redirect
I second TboneMofo's request....pleaseTboneMofo wrote:Can someone please post the complete instructions for this for Joomla! 1.5.22. I have tried several versions of the instructions in this thread, and none is working yet. I'm assuming it is because my version is newer than older sets of instructions.
Thank you in advance!
-
- I've been banned!
- Posts: 36
- Joined: Fri Feb 04, 2011 12:19 pm
Re: User Specific Login Redirect
i think this stracture is general and its not related to joomla versionbrergo wrote:I second TboneMofo's request....pleaseTboneMofo wrote:Can someone please post the complete instructions for this for Joomla! 1.5.22. I have tried several versions of the instructions in this thread, and none is working yet. I'm assuming it is because my version is newer than older sets of instructions.
Thank you in advance!