Thursday, November 19, 2009

Auto login to Joomla via a URL

Here is the instructions to implement auto login for Joomla via a URL.

Suppose if you are sending a newsletter to your customer with a link to your site, and if you want to autologin to your site when he click the link, then you cannot have this option in Joomla.

Thus I have created a function to accomplish this..

I will explain step by step about how to develop this,

First when the user clicks on the link, you need to make it to run a file, which will call this function below.

I have created this function when I am working with virtuemart.. And it is working right now without issues.

if you have trouble deploying this.. feel free to comment here :)


/* $d is an array which holds the userid and username.
$d["user_id"] = userid
$d["user_name"] = user name
*/



function quick_login($d){
global $mosConfig_absolute_path, $mosConfig_live_site,$_SESSION,$mainframe;;

if ($return = JRequest::getVar('return', '', 'method', 'base64')) {
$return = base64_decode($return);
if (!JURI::isInternal($return)) {
$return = '';
}
}

if( !isset($d['user_name']) || $d['user_name'] == ''){
$user = JUser::getInstance($d['user_id']);
$d['user_name'] = $user->username;
}

$options = array();
$options['remember'] = JRequest::getBool('remember', false);
$options['return'] = $return;

$credentials = array();
$credentials['username'] = $d['user_name'];
$credentials['password'] = '123'; //Give any thing
$mainframe->login($credentials);

$mainframe->redirect('index.php?option=com_user');
}

Tuesday, October 27, 2009

Welcome to my Weblabs.

I am a professional web developer,
Here I am going to list some interesting concepts of my web development experience.

This lab would give you tips on Developing Joomla, Wordpress, phpBB, etc.,