LMSouq
moodle-core Open

How to manually create a user in Moodle?

NA
Naner
1 month ago
3 views
Problem Description
I am trying to create an authentication plugin, but I am having problems when the user does not exist in the moodle database. Therefore I am trying to find a way to manually create a user. I tried: $user = new StdClass(); $user->username = $ucUser; $user->auth = 'ucauth'; $user->firstname = "First"; $user->lastname = "Last"; $user->id = $DB->insert_record('user', $user); But it didn't work... I got an insert error. What else do I need in the `$user` object?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base