Set priority of a plugin through code

how to set the priority of a plugin by default, so that after installation and activation it is at the bottom of 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 defult it is at the bottom of plugin list.

ihave tried:
elgg_register_event_handler('init', 'system', 'myplugin_init', 999999);
but it does'nt seem to work. please help.
Thanks in advance
Im using elgg 1.8.16

  • @gillie, no I did'nt, i'll try It now and respond back.

  • @ gille, @Juho Jaakkola  Yes that does the job, it sets the plugin as last, but, there is one problem, it does not show the required changes, imean when i create a new subdomain and visit the site i have to run to see the effect of code used to set the priority.
    this is needed for the first time only after that everything runs fine, can i automate this upgrade?

    Sorry If im unclear, please let me know.

    by the way I have included this code just before

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

    in the start.php of my plugin, is this the right place?

  • If your plugin is placed below the search plugin, then it will automatically override the search view (provided your view paths are same as that of search plugin). - PS : this is the correct way it has to be done.

    When the plugin positions are changed (plugins enabled /disables) via admin panel, the sites caches are flushed. You have to flush it manually if you are setting the priority via code. But generally speaking, setting the priority with in the init() is a bad choice, because it has to be run on everytime. 

  • @team webgalli: so where should i do it?

  • ok I have got the point, I have set the plugin priority just after the completion of installation process and have flushed the cache using elgg_reset_system_cache()
    and everything is working fine now, Thank you  gille, Juho Jaakkola , team webgalli . Thank you all a million for quick replies and immense help.