# Custom events

A custom event runs when the user presses a button of their own in the web interface. It turns a job into something a user can start themselves: "Send to archive", "Request approval", "Publish".

Three things belong together: a button, optionally a form, and the event.

## The button

On the [WebInterface](Users-WebInterface.md) tab, add a button of the kind **Custom** to the user's [buttons](Users-WebInterface-Buttons.md) and give it a name. The user selects files or folders in the list and presses it.

## The form

When the user shall be asked something first, such as a reason or an address, make a form in [Custom forms](Prefs-WebInterface-Custom-Forms.md) and choose it under **Custom Event Form** in the [forms](Users-WebInterface-Forms.md) of the user. The form opens when the button is pressed; the event runs when it is sent.

## The event

On the [Events](Users-Events.md) tab:

| Part | Set |
|---|---|
| **Action** | **Run Plugin** with a job, or **Send Email** |
| **Triggers** | **Custom**, under "When this user…" |
| **Timing & Delivery** | **Do event immediately** |

## What the job is given

One item per selected file or folder. Each item has the usual facts about the file and, beside them, what the user typed into the form. A field named `reason` in the form is `{meta_reason}` in the mail of the event and in the steps of the job.

The values of a form travel apart from the item's own facts, and a field whose name is that of a connection setting, or of one of the item's own values such as `the_file_name`, is left out and logged. A user so cannot steer the job anywhere else with a made-up request.

The answer the user sees is "SUCCESS", with what the job logged for them.

## Two relatives

| Trigger | Runs when |
|---|---|
| **Problem** | the user presses **Report A Problem**. The server first tries the storage of the selected item and adds the result of that test to the item: `Success`, or the error. An event with **Send Email** then brings report and test result to the help desk. |
| **Issues site command** | a program sends `SITE` with a command of your own, or the web interface's equal of it. The item carries the name of the command and its fields. The user needs **SITE PLUGIN** in [Site preferences](Users-Admin-Site-Preferences.md). |

## Example: ask for a file to be published

1. Form "Publish request" with one field, `reason`.
2. Button **Custom**, named "Publish".
3. **Custom Event Form**: "Publish request".
4. Event "publish" with trigger **Custom** and a job of two steps: copy the item to the folder of the web site, and mail the editors the name of the file, `{user_name}` and `{meta_reason}`.
