Problem Description
I am trying to automatically authenticate a user in Moodle but having trouble using authenticate_user_login in Moodle 3.8.3.
I have tested the below code but I get the following error:
Exception - Argument 1 passed to core\session\manager::login_user() must be an instance of stdClass, boolean given, called in [dirroot]/lib/moodlelib.php on line 4632
Appreciate your help.
```
<?php
require('config.php');
$name="myusername";
$password="mypassword";
$dashboard = $CFG->wwwroot;
$user = authenticate_user_login($name, $password);
if(complete_user_login($user))
{
echo "login";
}
else
{
echo "not login";
}
?>
```
AI-Generated Solution
Powered by LMSouq AI · GPT-4.1-mini
Analyzing problem and generating solution…
Was this solution helpful?