Creating Plugins for Metavus

Plugins are a way of adding new functionality to or modifying existing functionality of a Metavus site.  (They are not intended for purely cosmetic changes – if you want to change just the look and feel of your site, a new interface is probably a better choice, rather than a plugin.  See Creating Interfaces for more on interface creation and usage.)

Classes and Attributes

The core component of a Metavus plugin is a PHP class, with the plugin’s base name as the class name.  All plugins must be descendants of the \Metavus\Plugin base class, and at minimum must implement their own version of the register() method, to set the plugin attributes:

class ListSubscriber extends \Metavus\Plugin {
    function register() {
        $this->Name = "State University Library Mailing List Subscription Plugin";
        $this->Version = "1.0";
        $this->Description = "This plugin will add new users to the StateLib "
                ." mailing list when they verify their Metavus account, and remove"
                ." them if their account is deleted.";
        $this->Author = "John Doe";
        $this->Url = "";
        $this->Email = "";
        $this->Requires = [
            "MetavusCore" => "1.1.0",

The only attributes that must be set are $this->Name and $this->Version, but assigning values to the others is strongly encouraged, particularly if you may be sharing your plugin with others. The $this->Name attribute should contain a human-readable name for your plugin.

The $this->Requires attribute can be used to specify the minimum versions of other plugins that your plugin must have to run. The MetavusCore plugin can be required to ensure that your plugin is running under at least the specified version of Metavus.


Plugin configuration settings can be specified via the $this->CfgSetup attribute:

    $this->CfgSetup["SubConfirm"] = [
        "Type" => FormUI::FTYPE_FLAG,
        "Label" => "Subscription Confirmation",
        "Help" => "This determines whether new subscribers will be required to confirm their mailing list subscription.",
        "Default" => true,
        "OnLabel" => "Yes",
        "OffLabel" => "No",

The top-level index to $this->CfgSetup[] array is the setting name, which is what is passed in to $this->getConfigSetting() to retrieve the setting value.