I have a userId -
I wanted to make this user as logged in to the s/m in joomla.
I've tried this -
$currentUser = new JUser($uid); $mainframe = JFactory::getApplication('site'); $credentials = array(); $credentials['username'] = $currentUser->username; $credentials['password'] = $currentUser->password; //this is the hashed password //perform the login action $mainframe->login($credentials); $newuser = JFactory::getUser(); //this doesn't get updated to the new user ($uid) details
How can I make the user as the current user by using the uid itself?
Update: I just found that user can be loaded with JUser::load()
$user = JUser::getInstance($uid); $user->load($uid); //this should load the new user. $newuser = JFactory::getUser(); //still i get the anonymous details here //($newuser->id = 0)
As there is
wp_set_current_user($uid); for wordpress
user_load_by_name() in drupal, is there any similar function for joomla ? Please help.!!!