You are here

Discovering Hooks in Totara LMS 9

One of the key benefits of using Totara LMS is that it’s open source, so as a customer you can extend the platform to make it do exactly what you need. Rather than having to rework your company’s processes around the LMS, the LMS can be shaped to fit your requirements. And the great news is that with Totara LMS 9, we've taken one of the key benefits of Totara LMS and made it even better. 

Totara LMS is already very extensible due to its pluggable architecture - it’s very easy to create a new module to add new functionality, but what about when you want to make changes to the core platform itself?

Of course there’s nothing to stop you making core changes, but as the product evolves that comes with a cost - each time you want to upgrade Totara LMS to get the latest functionality, your customisation can lead to code conflicts that require additional work to fix. That's why we've created a new feature to help you make your LMS significantly more flexible.

In Totara LMS 9 we are introducing a powerful new feature called Hooks, which is designed to help solve this problem. As their name implies, hooks allow third party plugins to 'hook into' core functionality, giving them the opportunity to extend, modify or cancel the existing behaviour without causing the conflicts that can lead to extra work during upgrades.

To give a simple example, imagine the actions that might occur during the creation of a user in the site:

  1. Assign the correct data to the user (name, email address, etc.)
  2. Check the user is valid
  3. Create the user if it is valid

If we wanted to use hooks to let plugins influence that process, we would change the code to this:

  1. Assign the correct data to the user (name, email address, etc.)
  2. Run the 'Create User' hook, passing in the data from step 1
  3. Check the user is valid
  4. Create the user if it is valid

Any plugins you create could then choose to use the hook to make use of or modify the user’s data or even cancel the creation of the user completely. For example you could check the user’s details and prevent their creation if they didn’t meet some specific criteria. Or you could do an external lookup to your HR system and automatically populate the user with some additional data. Because of the design, the code you add will be part of your plugin and therefore won’t conflict with other code changes when the site is upgraded.

Totara LMS 9 adds the framework for building hooks into core code plus some example hooks in commonly customised areas (such as the course editing form). We’re actively encouraging our partners to submit code contributions to add hooks into places where they would find them useful.

Totara LMS 9

With hooks, customising Totara LMS to make it into the platform you need is easier and more maintainable than ever.

Got an idea for a new hook? Get in touch to discuss your thoughts or to find out more about contributing code to Totara products. 


Back to top