Loading Plugins Based on the User's Role

In some situations, it may be desirable to load different sets of plugins for different types of users. This can be done with any of the ways to load plugins, but it is easiest in most cases when loading the plugins from within the configuration file since most integrations have built-in support for role based configuration files.

To load plugins directly from the configuration file, simple include the same information from the separate plugin XML file directly in the configuration file under the <plugins> element. For example, the filter images plugin uses the XML file:

<?xml version="1.0"?>
<plugin load="lazy">
 <advancedapis jar="filterImages.jar"
  class="com.ephox.editlive.filterimages.FilterImages" />
</plugin>

However, this same information can be included directly in the configuration file instead:

<editlive>
  …
  <plugins>
   <plugin load="lazy">
    <advancedapis jar="path/to/filterImages.jar"
      class="com.ephox.editlive.filterimages.FilterImages" />
   </plugin>
  </plugins>
  …
</editlive>

Note that the URL for the JAR may need to be updated since it will now be relative to the page EditLive! is on rather than relative to the plugin XML file. Using the role-based configuration support in your integration, you can control which users have the plugins loaded, by either including or excluding the definition for the plugin in the configuration file.

Of course, if you are loading the plugin using the addPlugin or addPluginAsText JavaScript functions, you can simply use an if statement in either JavaScript or on the server side to control whether or not the plugins are loaded, however this is more difficult than using the configuration file in most integrations.