Can I register for an event or hook outside of start.php???

The title says it all.  Can I just register the event/hook listener and have my function in my start.php file??

  • start.php is called when the plugin is loaded. You can have start.php include any other file you want and do your event/hook registration in that file. Unless you have a good reason, I don't recommend breaking convention by moving around where you do the registration. Look to the bundled plugins for guidance. 

  • Well I am creating a plugin where the user (actually an admin) will define a hook that they want to listen in on, and the action for that form will use the php eval() function to run the code that the admin puts in.  So for example, let's say the admin wants to listen in on the event of a user logging in.  They would type register_plugin_hook('login', 'user', 'function_to_call'), and for arguments sake, assume that 'function_to_call()' is already defined in this plugin's start.php.  Then they would submit the form and the subsequent action that is called by the form runs that register_plugin_hook code with the eval() function.  I have tried exactly this, and it does not work.  I have noticed that plugins are loaded everytime a page is loaded (and many times).  So I guess my question is how can I get my functionality to work? 


    Would my only solution be to write the code the admin submits to a file that is then included in my start.php file?  I feel like all of those register_plugin_hook and register_elgg_event_handler calls would dramatically slow down the system (assume there are over 100 of these calls).