Inserting Users - SQL Insert or another way?

Inserting Users - SQL Insert or another way?

by Hugh Edwards -
Number of replies: 1

Hello Moodlers.

I want to be able to have my front-end website, (via some method, automatically enrol a user in Moodle and assign then to an appropriate course, based on choices they make on the front-end website (which is not Moodle).

Normally I would just write a bit of code to run a SQL insert and enter the user into the user table and then the course number/ID in the course link table. Is this the best way to do it, or is there a simpler and more recognised way of doing this? Perhaps via a widget/plugin etc? Or a different way that I'm just not aware of?

(Using V 2.5.1)

Thanks!

Hugh. x

Average of ratings: -
In reply to Hugh Edwards

Re: Inserting Users - SQL Insert or another way?

by Randy Thornton -

Hugh,

The recognized way is to have Moodle pull the data instead of pushing it. Much easier smile

Take a look at the External Database method for both authentication and also for enrolments. It's a typical good solution for your scenario. Bascially, you put the data in a local db and then Moodle handles all the synchronization and the hard parts for you.

http://docs.moodle.org/25/en/External_database_authentication

http://docs.moodle.org/25/en/External_database_enrolment

 

Randy