# General plugins development

## Hooks

Plugins can use "hooks", which are similar to what can be found in the Drupal CMS: places in the normal workflow of Chamilo where plugins can intervene.

It works in Chamilo by having the normal process, for example to delete a user, calling a special function that will look for any plugin installed and that implement a specific method.

The hooks are defined in `main/inc/lib/hook/` and are instanciated in the normal workflow. For example, in `usermanager.lib.php`, we find that the `UserManager::create_user()` method actually instanciates the HookCreateUser object and then calls one of its method:

```
        $hook = HookCreateUser::create();
        if (!empty($hook)) {
            $hook->notifyCreateUser(HOOK_EVENT_TYPE_PRE);
        }
```

Hooks also have to be defined in all plugins. See <https://github.com/chamilo/chamilo-lms/issues/1767> for a very short note on the issue of adding hooks halfway through a minor version, and on the existence of 3 functions (`doWhenDeletingCourse`, `doWhenDeletingSession` and `doWhenDeletingUser`) that are not implemented as hooks yet but that should be in 2.0.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chamilo.org/1.11.x/developer-guide/plugins/general_plugins_development.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
