> For the complete documentation index, see [llms.txt](https://docs.acymailing.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acymailing.com/developers/making-a-custom-add-on/execute-custom-script-on-specific-acymailing-actions.md).

# Execute custom script on specific AcyMailing actions

### Triggers/hooks on specific actions

To be able to use AcyMailing triggers, you first need to create a custom add-on:

{% content-ref url="/pages/VLLddwcCDTUdIQbdRCKy" %}
[Making a custom add-on](/developers/making-a-custom-add-on.md)
{% endcontent-ref %}

Once created, you can add the following methods in the **plugin.php** file of your add-on. They will be automatically called by AcyMailing if your add-on is active.

### When a user is created

You can use these methods to execute specific actions before/after a user is created.

```php
public function onAcymBeforeUserCreate(&$user) {
    // Your code here, $user is an object containing the AcyMailing user information
}

public function onAcymAfterUserCreate(&$user) {
    // Your code here, $user is an object containing the AcyMailing user information
} 
```

### When a user is modified

You can use these methods to execute specific actions before/after a user is modified.

<pre class="language-php"><code class="lang-php">public function onAcymBeforeUserModify(&#x26;$user) {
<strong>    // Your code here, $user is an object containing the AcyMailing user information
</strong>}

public function onAcymAfterUserModify(&#x26;$user) {
    // Your code here, $user is an object containing the AcyMailing user information
} 
</code></pre>

### When users are removed

You can use these methods to execute specific actions before/after one or several users are deleted.

```php
public function onAcymBeforeUserDelete(&$users) {
    // Your code here, $users is an array of AcyMailing user IDs
}

public function onAcymAfterUserDelete(&$users) {
    // Your code here, $users is an array of AcyMailing user IDs
}
```

### When the user is confirmed

```php
public function onAcymAfterUserConfirm(&$user) {
    // Your code here, $user is an object containing the AcyMailing user information
} 
```

### When the user subscribes to a list

This method is called after the user subscribes to one or several lists.

```php
public function onAcymAfterUserSubscribe(&$user, $lists) {
    // Your code here, $lists is an array of list IDs
} 
```

### When the user unsubscribes from a list

This method is called after the user unsubscribes from one or several lists.

```php
public function onAcymAfterUserUnsubscribe(&$userID, $lists) {
    // Your code here, $lists is an array of list IDs
} 
```

### When importing users

These two methods are called before users are imported. The first one is called for each user that is imported.

```php
public function onAcymBeforeUserImport(&$oneUser) {
    // Your code here, $oneUser is a user object
}

public function onAcymUserImport(&$users) {
    // Your code here, $users is an array of user objects
} 
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.acymailing.com/developers/making-a-custom-add-on/execute-custom-script-on-specific-acymailing-actions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
