eConcepts
Design Services
Testimonials
eConcepts have consistently delivered quality designs on time despite our demanding time schedules.
Thanks guys!

George Martin
Fluke Motorsport,
Bristol
Thank-you from transforming our website into an excellent tool for promoting our business!

John
Garden House Hotel, Stamford
Portfolio
Links
Joomla - How to give a registered user a specific page on login



Introduction

user redirection with joomlaWith Joomla, there are some optional modules to give this functionality - allowing a specific register user to have their own page. For example there is User Home Pages or Community Builder, however, sometimes these are overkill for what is a very simple problem - how to have a specific user view/redirected to a specific page when they log in.

I came across this solution on the Joomla Forums and have modified it slightly for our use. It allows you to select a specific page from a drop down that the user will be redirected to upon login and logout.

Solution

Step 1:
open the file: /administrator/components/com_users/users.xml

after line 13 find:
<param name="editor" type="editor_list" default="" label="User Editor" description="WYSYWYG Editor for this User" />


add:
<param name="login" type="page_list" 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="page_list" default="" label="Logout Redirection URL" description="What page will the login redirect to after user logout, if let blank will load module default" />


Step 2:
open file /index.php

around line 139 replace:
$mainframe->login();


with:
$mainframe->login(); // Per User Redirection $temp_my = $mainframe->getUser(); $params = new mosParameters( $temp_my->params ); $userRedirect = $params->get( 'login', '' ); if ($userRedirect) { $return = sefRelToAbs( "index.php?option=com_content&task=view&id=" . $userRedirect . "&Itemid=" . $userRedirect ); } $temp_my = '';


around line 168 replace:
$mainframe->logout();
with:
// Per User Redirection $temp_my = $mainframe->getUser(); $params = new mosParameters( $temp_my->params ); $userRedirect = $params->get( 'logout', '' ); if ($userRedirect) { $return = sefRelToAbs( "index.php?option=com_content&task=view&id=" . $userRedirect . "&Itemid=" . $userRedirect ); } $temp_my = ''; $mainframe->logout();


Step 3:
open file /administrator/components/com_users/users.class.php

around line 47 add:
function _form_page_list( $name, $value, &$node, $control_name ) { global $database; // compile list of the pages $query = "SELECT id AS value, title AS text FROM jos_content" ; $database->setQuery( $query ); $editors = $database->loadObjectList(); array_unshift( $editors, mosHTML::makeOption( '', '- Select Page -' ) ); return mosHTML::selectList( $editors, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value ); }


And you're good to go!


Summary

It's a nice quick hack. You can create a new page in the admin, set that page to registered then allow the user to drop straight in on that page so in effect it's their own 'custom' homepage. It would take a registered user 'guessing' the pageid/link to come across otherwise. Not perfect, but useful for such a quick hack. The limitation is on the screen it brings up - it's currently drawn flat. If you want to customise it with specific menus/layouts then edit the bit of code that creates the redirect in index.php with your own item/menu ids.

Alternatively, to get round this, you could replace the two calls to type="page_list" in the xml with type="text" and replace the two $return = sefRelToAbs( "index.php?option=com_content&task=view&id=" . $userRedirect . "&Itemid=" . $userRedirect ); with $return = sefRelToAbs( $userRedirect ); to have a raw text input. This would allow you to input any url you wish.

Added by Graeme Finlayson on 01/11/2007.

Comments

Make a Comment.

[home] | [about us] | [contact]

©www.eConcepts.co.uk