MyBB Community Forums

Full Version: Hooks for plugins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I think it'd be good if there were a lot more hooks available for use and if they were documented better. Currently the only real list just points to their line number which forces developers to keep looking back at the code, and sometimes there's actually no way to modify the data you need to while the hook is called, so I think it'd be awesome to have hooks cleared up and moved to places where it can actually be used (For example, when searching in the AdminCP, the hook is called at the start of the method, which will not allow any modification to the results, see this) and including data that can easily be modified, instead of just 'being there', they would be even more useful and flexible.

Hooks should be implemented for almost all core functions like formatting names (Which should be used everywhere a name is shown, or of course a central function to set the display name before formatting/putting into a link), pages which display data of some kind (Searches, Forum Indexes etc) should have an easy way to modify the data (Passing the array even, but some hooks are in bad positions that cannot modify outgoing data, even then the html output is set before it's even usable by any hook right now)

Hooks should also be documented differently, if they have data that can be modified it should be defined in a documentation page like Java's javadoc generated pages, it might be a big project but it'd speed up development time for a lot of plugin developers.

This is kind of a big change for 1.6, so if it would be nice to see implemented in 1.8 before the release Smile
Definitely agree that hooks need a lot more documentation, it is pretty annoying having to look through the core or through other plugins with similar functionality to what you want to figure out how to use the hooks properly.
I think just about everybody agrees the current documentation on the process of creating a plugin sucks. I've been meaning to take a look at padding out the docs a bit at some point since before Christmas now.
In a way though it is a good thing to become (and stay) familiar with the MyBB core source code.

I have learned a lot about how things work when I was searching for the correct hook to use.

I am certainly not saying documentation is perfect :p
Anyone is free to update the docs if they wish.
I never look at documentation to find out which hooks to use.

If you modify anything that MyBB works with you have to look at the code anyway.

Easiest way to find the hooks you can use for a particular page is to add a debug message to run_hooks(_by_ref) to make them print out the names of the hooks being run.
We can't add hooks everywhere because it will have a performance impact on the forums.
Wordpress doesn't seem to care about that... just look at their most recent update.. it's a hog ;P
Is there any benchmarks avail for MyBB?? -with default setup and normal operations

+1 that the MyBB docs for hooks are short of something to be desired...
imo the whole thing could use a face lift and be fleshed out more.
Digging through core php just to discover what does what works but is not as time efficient as learning it from good documentation.

idea: get a hub for technical plugin experts to submit blocks of tutorial data and have a designer format it all logically and aesthetically. Then publish it.
I agree that the documentation needs updating. All I found was a list of all plugin hooks. It works, but it requires a little trial and error to make sure it works.

More hooks I can agree on but don't go overboard. I like the speedy performance of MyBB.

One thing I want: more data passed to each hook. I want to tweak things and pass back things to the core code, but I can't.