# Events

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.&#x20;
{% endhint %}

## Introduction

Plugin developers can hook into various e107 core events and [trigger functions of their own](#trigger). Typically, an [e\_event.php](https://devguide.e107.org/plugin-development/extending-core-functionality-addons#e_event-php) file is used to store this information since it is loaded with every page.

{% hint style="info" %}
From e107 version 2.1.2 onwards you can use [e\_event.php](https://devguide.e107.org/plugin-development/extending-core-functionality-addons#e_event-php) addon to catch the events instead of using [e\_module.php](https://devguide.e107.org/plugin-development/extending-core-functionality-addons#e_module-php)
{% endhint %}

## &#x20;Events methods

### register()

| Parameter    | Description                                                                                                                        | Mandatory? |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| **name**     | The event you wish to hook into. ([see tables below](#event-triggers))                                                             | **Yes**    |
| **function** | Your function or class/method to trigger when this event occurs. string for function, or for classes use an array (class, method). | **Yes**    |
| include      | include (optional) path: a file to include if required.                                                                            | No         |

```php
e107::getEvent()->register(name, function, include);
```

#### **Example 1**: trigger `myFunction()` on user login.

```php
e107::getEvent()->register('login', 'myFunction'); 

function myFunction($data)
{
   // do something    
}
```

#### **Example 2**: trigger `myFunction()` on user login. Function in external file.

```php
e107::getEvent()->register('login', 'myFunction',  e_PLUGIN."myplugin/myFunctions.php");
```

#### **Example 3**: trigger a class and method on user login.

```php
e107::getEvent()->register('login', array('myClass', 'myMethod'),  e_PLUGIN."myplugin/myClass.php");
```

### trigger()

Triggers an event. This can be used by plugin authors to create their own plugin events that other developers can hook into.&#x20;

```php
e107::getEvent()->trigger($eventname, $data = '');

// Example for plugin authors to create their own plugin event:
e107::getEvent()->trigger("plugindir_customevent", $data = ''); // plugindir is the name of the plugin folder
```

| Parameter     | Description                                                                                                                                                | Mandatory? |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| **eventname** | <p>The name of the event you wish to trigger (new event name). <br><br><em><strong>Format:</strong></em> plugindir\_eventname<br>(see example above). </p> | **Yes**    |
| data          | The data that you wish to send alongside the event                                                                                                         | No         |

## Core Event triggers

### User Event Triggers

#### Basic user functions&#x20;

| Trigger Name            | Description                                                                    | Data                                           |
| ----------------------- | ------------------------------------------------------------------------------ | ---------------------------------------------- |
| login                   | User login/signin                                                              | Array of user data                             |
| logout                  | User logout/signout                                                            | Notice event                                   |
| user\_file\_upload      | User uploads a file                                                            | Array of file information                      |
| user\_signup\_submitted | User submits signup form                                                       | Array of user data                             |
| user\_signup\_activated | User activates newly created account. (email link)                             | Array of user data                             |
| user\_xup\_login        | User signs in via a social media account. eg. Facebook, Twitter etc.           | Array of user data                             |
| user\_xup\_signup       | User creates an account using their social media login. Facebook, Twitter etc. | Array of user data                             |
| user\_profile\_display  | User has viewed a profile                                                      | Array of data                                  |
| user\_profile\_edit     | User has edited their profile                                                  | Array of data of user who changed the settings |
| user\_comment\_posted   | User has posted a new comment                                                  | Array of data                                  |
| preuserset              | Before usersettings are updated                                                | Array of new user settings ($\_POST)           |
| postuserset             | After usersettings are updated                                                 | Array of new user settings ($\_POST)           |
| userdatachanged         | After usersettings are updated (same time and data as user\_profile\_edit)     | Array of data of user who changed the settings |

#### **Custom page**

| Trigger function         | Description                   | Data          |
| ------------------------ | ----------------------------- | ------------- |
| user\_page\_item\_viewed | User has viewed a custom page | Array of data |

#### **News**

| Trigger Name             | Description                | Data          |
| ------------------------ | -------------------------- | ------------- |
| user\_news\_item\_viewed | User viewed a news item    | Array of data |
| user\_news\_submit       | User submitted a news item | Array of data |

#### **Private Messenger**

| Trigger name   | Description                     | Data          |
| -------------- | ------------------------------- | ------------- |
| user\_pm\_sent | User has sent a private message | Array of data |
| user\_pm\_read | User has read a private message | Array of data |

#### **Forum**

| Trigger Name                              | Description                                     | Data          |
| ----------------------------------------- | ----------------------------------------------- | ------------- |
| user\_forum\_topic\_created               | User creates a forum topic                      | Array of data |
| user\_forum\_topic\_created\_probationary | New user creates a forum topic                  | Array of data |
| user\_forum\_topic\_updated               | User updates a forum topic                      | Array of data |
| user\_forum\_topic\_deleted               | User deletes a forum topic                      | Array of data |
| user\_forum\_topic\_moved                 | User has moved forum topic to a different forum | Array of data |
| user\_forum\_topic\_split                 | User has split the forum topic                  | Array of data |
| user\_forum\_post\_created                | User creates a forum post/reply                 | Array of data |
| user\_forum\_post\_updated                | User updates a forum post/reply                 | Array of data |
| user\_forum\_post\_deleted                | User deletes a forum post/reply                 | Array of data |
| user\_forum\_post\_report                 | User has reported a forum post/reply            | Array of data |

#### **Chatbox**

| Trigger function             | Description                       | Data                           |
| ---------------------------- | --------------------------------- | ------------------------------ |
| user\_chatbox\_post\_created | User has posted a chatbox message | Array of data (ip and message) |

### Admin Event Triggers

#### **Admin changes their password**

| Trigger Name            | Description                  | Data                                          |
| ----------------------- | ---------------------------- | --------------------------------------------- |
| admin\_password\_update | Admin updates their password | Array containing user\_id and time of change. |

#### **Comments Manager**

| Trigger Name           | Description             | Data                  |
| ---------------------- | ----------------------- | --------------------- |
| admin\_comment\_update | Admin updates a comment | Array of comment data |
| admin\_comment\_delete | Admin deletes a comment | Array of comment data |

#### **Downloads**

| Trigger Name            | Description                   | Data                   |
| ----------------------- | ----------------------------- | ---------------------- |
| admin\_download\_create | Admin creates a download item | Array of download data |
| admin\_download\_update | Admin updates a download item | Array of download data |
| admin\_download\_delete | Admin deletes a download item | Array of download data |

#### **News**

| Trigger Name                  | Description                   | Data               |
| ----------------------------- | ----------------------------- | ------------------ |
| admin\_news\_create           | Admin creates a news item     | Array of news data |
| admin\_news\_update           | Admin updates a news item     | Array of news data |
| admin\_news\_delete           | Admin deletes a news item     | Array of news data |
| admin\_news\_category\_create | Admin creates a news category | Array of news data |
| admin\_news\_category\_update | Admin updates a news category | Array of news data |
| admin\_news\_category\_delete | Admin deletes a news category | Array of news data |

#### **Pages**

| Trigger Name        | Description                    | Data                             |
| ------------------- | ------------------------------ | -------------------------------- |
| admin\_page\_create | Admin creates a page/menu item | Array of page data               |
| admin\_page\_update | Admin updates a page/menu item | Array of page data (new and old) |
| admin\_page\_delete | Admin deletes a page/menu item | Array of page data               |

#### **Users**

| Trigger Name          | Description                        | Data                             |
| --------------------- | ---------------------------------- | -------------------------------- |
| admin\_user\_create   | Admin creates a new user           | Array of user data               |
| admin\_user\_update   | Admin modifies user data           | Array of user data (new and old) |
| admin\_user\_delete   | Admin deletes a user               | Array of user data               |
| admin\_user\_activate | Admin activates an unverified user | Array of user data               |
| admin\_user\_loginas  | Admin logs in as another user      | Array of user data               |
| admin\_user\_logoutas | Admin logs out as another user     | Array of user data               |


---

# 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://devguide.e107.org/classes-and-methods/events.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.
