Create User Plugin w/web services

Create User Plugin w/web services

av Derek Smith -
Antall svar: 5

Hi Everyone,

I'm new to moodle and don't know how to write a plugin.

I'm looking for a plugin (or another mechanism) that does the following upon creation of a user:

1. Send user profile information & custom properties it to another external database using a POST web services method

2. Places the user into courses and cohorts.

Is this possible? Or is there an example I can use?

Thanks for your help!

Gjennomsnittlig vurdering: -
Som svar til Derek Smith

Re: Create User Plugin w/web services

av Emma Richardson -
Bilde av Documentation writers Bilde av Particularly helpful Moodlers Bilde av Plugin developers

The external database authentication will take care of the first part.

This can be achieved in many ways but will depend on how you intend to tell Moodle what courses and cohorts the user should be placed in....

Have you checked the plugins database?

Som svar til Emma Richardson

Re: Create User Plugin w/web services

av Derek Smith -

Thanks for your help emma. The issue is that we don't have access to their moodle external database and there are three external databases that we have that need fields from moodle's user profile information . I'm okay with using the excel sheet for the upload of users into say 20 generic courses and 1 cohort.

However, in order for the custom applications we have to work with moodle's platform. We need an plugin that monitors when a user is created and then sends out the user profile information to the three separate databases. Do you have any insight into this?

Som svar til Derek Smith

Re: Create User Plugin w/web services

av Justin Hunt -
Bilde av Particularly helpful Moodlers Bilde av Plugin developers

Hi Derek

Moodle creates events on certain actions, and there is an event when a user is created. 

The "Trigger" plugin can post the event data to a URL that you specify. It won't just pop them users into the databases though, you would need some custom code or a middle man application (eg zapier) to handle that. The trigger plugin is not yet on the plugins database yet. But it will go up later in the year I hope. This thread talks about it a bit more...

https://moodle.org/mod/forum/discuss.php?d=369331#p1489092

You can see it in action at the Moodle Japan Innovations showcase site here (you will need to register on the site): 

https://showcase.moodlejapan.org/inno/course/view.php?id=10


Gjennomsnittlig vurdering:Useful (1)
Som svar til Justin Hunt

Re: Create User Plugin w/web services

av Derek Smith -

Yes! It works! Thank you Justin! This was exactly what I was looking for! Running it on moodle 3.2.

Going through initial testing, I did notice that if I use the same trigger (e.g. user created) twice with different webhook receiver htmls, I receive duplicates POSTs on the webhook receiver. However, this is fine, since I can just reject the duplicate.

I'll report back if I have any more questions.