Custom plugin development for Moodle™

Sometimes Moodle almost does what you need. I build custom plugins for the gap, and I start by checking whether you need one at all. When you do, it is built the way Moodle expects, so it keeps working after your next upgrade instead of becoming the thing that blocks it.

In short: Rohin Grover builds custom Moodle plugins to Moodle's own conventions (version.php, an XMLDB schema with upgrade steps, capabilities, language strings, and the task, hooks and privacy APIs), checks first whether a core setting or an existing plugin already does the job, and has built plugins for clients such as Grupo HEMO and PositiveMatters.

First, whether you need a plugin at all

Plenty of requests that arrive as "we need a plugin" are already met by a core setting, by a maintained plugin from the Moodle Marketplace, or by a change to roles and capabilities. Moodle's report builder, in core since 4.0, answers a lot of reporting requests with no code at all. I will say so before quoting build work, because a plugin you do not need is one more thing to carry through every upgrade.

Plugins and custom development I have built

  • Grupo HEMO, medical education. The training videos are hosted on Bunny Stream rather than inside Moodle, and the client needed each video to carry a mark tied to whoever was watching it. No existing plugin did that, so I wrote one that lays a watermark generated for each viewer over the video as it plays, to discourage screen recording and redistribution.
  • PositiveMatters, a UK training provider on IOMAD. Company Login Link (local_companyloginlink) gives each client company its own branded entry point to the shared platform. It needed supporting changes in IOMAD's own code, a trade-off explained further down this page.
  • Language and Learning Foundation, a teacher-training programme. Learner, course and quiz dashboards, a mentor report, and state and district completion reports that core Moodle does not provide, each exportable to Excel.
  • My own plugins, in development. Completion Doctor shows why a learner is not marked complete in a course and what still blocks it. Rolling Deadlines moves deadlines with each learner's own enrolment date where core Moodle does not. Neither is released yet, and Completion Doctor will be free when it is.

How a plugin is built so it survives upgrades

Moodle has a convention for almost every part of a plugin. Following it is what lets the plugin install cleanly, upgrade cleanly, and stay readable to the next developer who opens it. On a typical build that means:

  • The right plugin type and name. A report is a report_ plugin, an activity a mod_ plugin, and a site-wide tool usually a local_ or tool_ plugin. The full component name, such as report_completiondoctor, decides where the code lives and how its classes, strings and capabilities are named.
  • version.php with real constraints. $plugin->requires sets the oldest Moodle the plugin will install on, $plugin->supported the range of Moodle branches it supports, and $plugin->dependencies any other plugin it needs.
  • Database changes through Moodle's own tools. Tables are declared in db/install.xml, and every later change is a step in db/upgrade.php that ends with a savepoint, so a site that skips three versions of the plugin still upgrades through each step in order. No raw SQL against the schema.
  • Capabilities in db/access.php. Who can see or do what is a capability with a default for each role, so your administrators can change it without touching code.
  • Strings in language files, so the interface can be translated or reworded without editing PHP.
  • Background work through the task API. Scheduled tasks are registered in db/tasks.php and run by Moodle's cron, and administrators can see and change their schedule from the site administration pages.
  • Hooks and events instead of core edits. Callbacks registered in db/hooks.php, and observers of Moodle's events, let a plugin react to what core does, such as a user being enrolled, without changing core files.
  • A privacy provider. Every plugin declares what personal data it stores, or that it stores none, so the site can still answer data export and deletion requests under GDPR.

Versions matter as well. Since Moodle 5.1, plugin code lives under the public directory, for example public/local/yourplugin, and a plugin carried over from an older site has to be moved there by hand. Moodle 5.3 deprecates loading Bootstrap's JavaScript modules from theme_boost/bootstrap/*, so plugin JavaScript written that way needs changing before the old path is removed. This is why the branches a plugin supports are written down in version.php and tested, not assumed.

When a requirement reaches into core

Some requirements cannot be met from inside a plugin. Company Login Link is an example: it needed changes in IOMAD's own code. That is sometimes the right call, but it has a cost you should know about before agreeing to it. A change to core, or to IOMAD's code, has to be carried forward by hand at every upgrade, and a plugin that depends on one cannot be offered on the Moodle Marketplace as a self-contained plugin. I will tell you when a requirement crosses that line, and look for a hook, an event or a renderer override that avoids it first.

Tests and handover

Moodle has two test frameworks: PHPUnit for the code underneath and Behat for what a user clicks through. For a plugin that will live on a production site for years, ask for tests in the scope; they are what turn the next upgrade into a check rather than a guess. Moodle HQ's moodle-plugin-ci tool runs those tests together with Moodle's code style, PHPDoc, template and JavaScript checks, and can run them on each Moodle branch the plugin supports.

A Moodle plugin is PHP source that sits on your own server, so another developer can pick it up later. Writing it to Moodle's conventions is what makes that practical.

How to start

Describe the workflow you want in your own words, with the Moodle version and whether the site runs IOMAD. That is enough to tell whether it is a plugin, a setting or a report. Use the contact page or book a free 30-minute call. If you are in the US, the UK, Europe or Australia, how working with me remotely runs covers time zones, scope and payment. For multi-tenant platforms, see setup and development for IOMAD.

Common questions

Do I need a plugin, or can Moodle do it already?
Check first. Many requests are already met by a core setting, by the report builder that has been in core since Moodle 4.0, by a change to roles and capabilities, or by a maintained plugin from the Moodle Marketplace. A plugin you do not need is one more thing to carry through every upgrade, so I will say so before quoting build work.
Can a plugin change how Moodle core behaves?
Often, without touching core. Moodle's hooks API and its events let a plugin act when core does something, such as enrolling a user, and a theme can override templates and renderers. When none of those reach far enough, the remaining option is a change to core itself, which then has to be carried forward by hand at every upgrade. I will tell you before it comes to that.
Will a custom plugin survive Moodle upgrades?
It should, if it is built to Moodle's conventions: schema changes through db/install.xml and db/upgrade.php, background work through the task API, and no edits to core. It still needs checking against each new Moodle release, because Moodle deprecates old APIs and later removes them. Moodle 5.1, for example, moved plugin code under a public directory, so a plugin carried over from 4.5 has to be moved there by hand.
Will the plugin work on IOMAD?
Only if it is tested there. IOMAD changes parts of Moodle core and adds companies, so a plugin that touches users, enrolment or reports has to know about companies, or it can show one company's data to another. When the plugin will run on IOMAD, it is built and tested on IOMAD.
How much does a custom plugin cost?
It is quoted once the requirement is written down and, on an existing site, after a look at the Moodle version and the plugins it already runs, because a small block and an integration with an outside system are different jobs. Small plugins with a clear scope can also be ordered through my Fiverr profile, which shows the current prices.

Talk it through with Rohin

Bring the messy version of the problem. A free 30-minute session is usually enough to tell you whether it is a small fix or a real project, and what it would take either way.

Rohin's Brain
Ask about Moodle, multi-tenancy with IOMAD, plugins, reports, support, or whether your project is a fit for Hooknot Digital.