There are plenty of hooks throughout this forum software’s code which you can hook onto your own plugins. The intention behind hooks is to provide a framework for developers wishing to add onto their forum, or extensibility. If you’re looking to create a plugin but can’t find the hook that you need, don’t hesitate to start a new conversation about it.
The syntax to hook your own code onto one of these hooks is this:
$controller->addHook(“hookName”, “yourFunction”);
For example, to hook the function addSignatureToPostArray
onto the getPost
hook in the Conversation controller, the following would be used:
if ($this->eso->action == "conversation") {
$this->eso->controller->addHook("getPost", "addSignatureToPostArray");
}
Here is another example from the Debug plugin in which two functions are hooked onto the beforeDatabaseQuery
and afterDatabaseQuery
hooks:
function init()
{
parent::init();
// Add hooks to be run before and after database queries.
$this->eso->addHook("beforeDatabaseQuery", array($this, "startQueryTimer"));
$this->eso->addHook("afterDatabaseQuery", array($this, "addQuery"));
// Add a hook to the bottom of the page, where we'll output the debug information!
$this->eso->addHook("pageEnd", array($this, "renderDebug"));
}
Some hooks allow a value to be returned which may halt any further processing in the context of the hook from occurring. One such example is the validateAddReply
hook in the Conversation controller which will display a message identified by the return value of a hooked function (if applicable).
Note that $this
is an instance of the eso controller in this next list of hooks as with the Conversation controller and so forth.
beforeDatabaseQuery(&$this, &$query); // Before a database query is executed.
afterDatabaseQuery(&$this, $query, &$result); // After a database query is successfully executed.
init(&$this); // eso controller initialization.
beforeLogin(&$this, &$components); // Before the login query is constructed and executed.
logout(&$this); // When the user logs out.
getStatistics(&$this, &$result); // When forum statistics are fetched.
ajax(&$this, &$return); // When an AJAX request to the controller is made.
star(&$this, $conversationId); // When a conversation is starred or unstarred.
changeMemberGroup(&$this, &$group); // Changing a member's group.
finishAjax(&$result); // Before the $result array is outputted as a JSON string.
pageStart(&$this); // Situated directly before the <body> tag.
pageEnd(&$this); // Situated directly after the <body> tag.
head(&$this, &$html); // When the $html to go inside the <head> tag is generated.
message(&$this, &$key, &$disappear, &$arguments); // When a message is collected to be displayed on the page.
fatalError(&$this, &$message); // When the path to a user's avatar is gotten. Can return an avatar path.
updateLastAction(&$this, &$action); // When updating a user's last action in the database.
// to be added
init(&$this); // Before a list of feed items is constructed. Can return something.
formatPost(&$this, &$post); // When post content is formatted before being added to the list of feed items.
init(&$this); // Join controller initialization.
validate(&$this, &$validationError); // When the form fields are validated.
beforeAddMember(&$this, &$insertData); // Before the query to add a member is constructed and executed.
afterAddMember(&$this, $memberId); // After the query to add a member is executed successfully.
ajax(&$this); // When an ajax request to this controller is made. Can return something.
init(&$this); // Profile controller initialization.
ajax(&$this); // When an ajax request to this controller is made. Can return something.
beforeGetMember(&$this, &$components); // Before the query to get member details is constructed and executed.
afterGetMember(&$this, &member); // After the query result has been put into an array.
statistics(&$this); // When the list of member statistics is outputted.
init(&$this); // Search controller initialization.
ajax(&$this); // When an ajax request to this controller is made. Can return something.
getConversationIds(&$this, &$components); // Before the query to get a list of conversation IDs is constructed and executed.
beforeGetResults(&$this, &$components); // Before the query to get the resulting conversations is constructed and executed.
afterGetResults(&$this, &$results); // After the resulting conversations have been fetched and an array constructed.
init(&$this); // Settings controller initialization.
ajax(&$this); // When an ajax request to this controller is made. Can return something.
validateForm(&$this, &$validationError); // When the form fields are validated.
beforeSave(&$this, &$updateData); // Before the query to save settings is constructed and executed.
afterSave(&$this); // After the query to save settings is executed successfully.
resizeAvatar(&$this, $imageResource, $destination, $type, $resizeWidth, $resizeHeight);
// When an avatar is resized to $resizeWidth by $resizeHeight. Returning true will skip the default resizing process.
Join the community support forum and if that doesn't work, consider asking your question on the Discord server!