MyBlogPlanner

May 27th, 2009

Auto Login Joomla function

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. :)



10 Responses to “Auto Login Joomla function”

  1. 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

  2. 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

  3. 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.

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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?

  9. Umesh Chandra Says:
    October 5th, 2009 at 3:02 am

    Hi Dear
    This is realy very good code function for auto login in joomla
    Thanx
    Umesh chandra

  10. 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.

Leave a Reply