Reputation: 487
Does anyone have any insight into how this could be accomplished?
I figure that it may be possible to mess with the session unless there is already a built in function that could be used to do this.
If you need more information just let me know, I would be happy to provide it.
Thanks!
Upvotes: 0
Views: 935
Reputation: 3731
The following code snippet should load a user based on their id from the database and then log them in for the visitor making the request. It does not require their password. That being said, I do hope that you are authenticating this in some way. (And I have only tested this on the front-end of the site.)
$db = JFactory::getDbo();
$q = "SELECT * FROM `#__users` WHERE id = ".$id;
$user = $db->setQuery($q)->loadAssoc();
JPluginHelper::importPlugin( 'user' );
$dispatcher = JDispatcher::getInstance();
// Initiate log in
$options = array('action' => 'core.login.site', 'remember' => false);
$results = $dispatcher->trigger('onUserLogin', array($user, $options));
Upvotes: 2