Auto Login Joomla function
| May 27, 2009 | Posted by Subikar under cms, it professional, joomla, myblogplanner |
One of my client always like to sent mail to his members with updates of the website to make them participate. For long time he was demanded me a auto login system in joomla.
Today at last we got the solution how we can do it. I am sharing this with you hope that may help a lot of people.
function FnAutoLogin($ActivateID)
{
global $mainframe;
$db = JFactory::getDBO();
$Password = FnGenerateNewPassword(’9′); // Generating joomla password
//Fetching User Details according to Activation ID start
$query = “select * from #__users where activation=’”.$ActivateID.”‘”;
$db->setQuery( $query );
$UserDetailsInArray = $db->loadObjectList();
//Fetching User Details according to Activation ID end
if(isset($UserDetailsInArray[0]))
{
$TempPassword = $UserDetailsInArray[0]->password; // Storing user actual password
$query1 = “update #__users set password=’”.$Password.”‘ where activation =’”.$id.”‘”; //Updating temporary password
$db->setQuery( $query1 );
if($db->query())
{
// User Login start
$usersipass['username'] = $UserDetailsInArray[0]->username;
$usersipass['password'] = ’9′;
$mainframe->login($usersipass);
// User Login end
$query1 = “update #__users set password=’”.$TempPassword.”‘, block=0 where activation =’”.$ActivateID.”‘”; //Update user actual password againand redirect to your appropriate page you like ![]()
$db->setQuery( $query1 );
if($db->query())
{
$Msg = ‘Please upload your picture to see your profile.’;
$mainframe->redirect( ‘index.html’,$Msg);
}
}
}
else
{
echo ‘You don\’t have account yet? <a href=”/join.html”>Join Us Today </a>’;
}
}
Hope this will help a lot of developer to make auto login system in joomla.
Hi there,
thanks for the code! But where do I add this function? I’m looking now in components\com_users\controller.php (jmla vers. 1.5). Or do I need to write a complete new plug-in for joomla?
Thanks in advanced. Regards,
Stefannno
you can create new task in com_user and call this function. other information is already there in the blog post. Let me know if you need any help.
Thanks,
Subikar
Subikar thnx for your fast reaction!
I’m really new to this so it’s a bit hard to understand everything. But I will give it a try.
Is it possible you change the file’s? Or is it way 2much work? Or do you have an example for me?
Thanks in advanced.
It is not too tough but you need be familer with joomla component. If you need us to do it for you you can send us a request here to implement it.
http://www.itcslive.com/order-now.html
Thanks,
Subikar
Ok thank you, well i’m a bit familer. I already made a new task. But need another step. What are the costs? So I can think about it:).
Thanks
You can do one thing you can send your full details what you need with the full requirement. I hope it will not cost you more then $20.
Thank you,
Subikar
Ok sounds great:) I already checked the site but which option do I have to choose?(Product You interested to develop)
And the only thing I want is to send an e-mail with an link so the users login on my page on various locations.
Thanks
Can this allow the user to login and stay logged in for a period of time? We are requiring visitors to have user accounts to do specific functions. So we would like to be able to allow the user to auto login after that. Maybe a mix of a cookie and this?
Hi Dear
This is realy very good code function for auto login in joomla
Thanx
Umesh chandra
Can this allow the user to login and stay logged in for a period of time? We are requiring visitors to have user accounts to do specific functions. So we would like to be able to allow the user to auto login after that. Maybe a mix of a cookie and this?
Hi Jack I hope we can do. Just try the login function there may be some parameter to set to do that. If you need my help I can try to find out.
Hello subikar, thanks for your script autologin, i add that function in com_user/controller.php
but could yoy help me, where i will call the that function?? thanks for your help.
Regards
One thing that I find the most helpful is number five. Sometimes when I write, I just let the flow of the words and information come out so much that I loose the purpose. It’s only after editing when I realize what I’ve done. There’s defiantly a lot of great tips here I’m going to try to be more aware of.
What’s really doing the login is this code:
$credentials['username'] = ‘myUsername’;
$credentials['password'] = ‘myPassword’;
$mainframe->login($credentials);
yes It is login code
Hey , i would like to say thank you about your awesome post, very helpful to me, Many Thanks.
hehe its all normal m8 just put it on a spot where he will be likely to bite it =) or put it in his food bowel. but the 1st option works for me
Appreciate it to get stating plus releasing me personally this particular.
Good day!
sorry for the ignorance but from what file in joomla where will i copy this?
Thanks
components\com_users\controller.php you can write in the function register_save()
after this line UserController::_sendMail($user, $password);
Remember you must have good knowledge in php and mysql.
Thanks for the auspicious writeup. It if truth be told was once a entertainment account it. Look advanced to far delivered agreeable from you! However, how can we be in contact?