Search code examples
elgg

how to set the default priority of a plugin programatically in elgg


How can I set the priority of a plugin by default, programatically, so that after installation and activation, it is shown at the bottom of the plugin list automatically.

I know that we can set the priority in the administration section but how can we set that in code, so that when this plugin is installed on another site, by default it is at the bottom of plugin list.

I have tried:

elgg_register_event_handler('init', 'system', 'myplugin_init', 999999);

but it doesn't seem to work, and I can't find anymore documentation on it.

I'm using elgg 1.8.16


Solution

  • I have used this to set the priority last, but only setting the priority does not work until you clear the cache.

    $plugin = elgg_get_plugin_from_id('myplugin');
    $plugin->setPriority('last');
    

    I have used the following function for setting the priority as it runs once per installation. run_function_once($functionname, $timelastupdatedcheck = 0)

    and have flushed the cache after that using elgg_reset_system_cache()