Hi fellas,
I'm developing a plugin, which would let us connect to our moodle site using Atlassian Crowd credentials. So far, I developed first part, where user logs in moodle site, entering his/her credentials. As I understood, moodle creates a new user with auth='crowd' type.
After user logs in, the first page is shown to him/her is profile page, where all data is empty, so the user should fill it up by himself.
Could you suggest, which way should I pick here:
* write a pre-sync users from Crowd, so that when a user logs in all data was in place with confirmed email and so
* or write user_authenticated_hook($user, $username, $password) so that a newly created user's data was populated right after it was created.
For testing I wrote this one, which looks pretty ugly:
----
//function user_authenticated_hook(&$user, $username, $password) {
// global $DB;
// $transaction = $DB->start_delegated_transaction();
// $sql = "update mdl_user
// set firstname=:fn,
// lastname=:ln,
// email=:em,
// city=:ci,
// country=:co,
// confirmed=:cf
// where 1=1
// and username='$username'
// ";
// $DB->execute($sql, array(
// 'fn'=>$this->employees[$username]['firstname'],
// 'ln'=>$this->employees[$username]['lastname'],
// 'em'=>$this->employees[$username]['email'],
// 'ci'=>$this->employees[$username]['city'],
// 'co'=>$this->employees[$username]['country'],
// 'cf'=>1,
// ));
// $transaction->allow_commit();
//}
----
Thanks,
Ivan.