task_log_add

Triggered upon the execution of an action on a task.

Teamwork

Input (passed by reference)

$params['task'] array Task properties as an array with the following keys:
$params['task']['id'] int Task ID.
$params['task']['name'] string Task name.
$params['task']['create_contact_id'] int ID of the user who has added the task.
$params['task']['create_datetime'] datetime Task creation date and time.
$params['task']['update_datetime'] datetime Date and time of the most recent task update.
$params['task']['assigned_contact_id'] int|null Assigned user ID.
$params['task']['project_id'] int ID of the project to which the task belongs.
$params['task']['milestone_id'] int|null ID of the milestone to which the task belongs.
$params['task']['number'] int Task number within its project.
$params['task']['status_id'] int Task status ID.
$params['task']['priority'] int Priority value.
$params['task']['assign_log_id'] int ID of the latest task assignment log entry.
$params['task']['hidden_timestamp'] int|null Timestamp of the date and time until which the task was marked as hidden.
$params['task']['due_date'] date Deadline date.
$params['task']['comment_log_id'] date ID of the latest task comment adding log entry.
$params['task']['uuid'] string Global task identifier.
$params['task']['public_hash'] string|null Hash string used in the task’s public link URL.
$params['log'] array Tasks processing log entries as an array with the following keys:
$params['log']['id'] int Log entry ID.
$params['log']['task_id'] int Task ID.
$params['log']['project_id'] int ID of the project in which the task landed after the execution of an action.
$params['log']['contact_id'] int ID of the contact who executed the action.
$params['log']['text'] string Text entered during the execution of the action.
$params['log']['create_datetime'] datetime Date and time of the action execution.
$params['log']['before_status_id'] int ID of the task status before the action execution.
$params['log']['after_status_id'] int ID of the task status after the action execution.
$params['log']['action'] string Task action type.
$params['log']['assigned_contact_id'] int ID of the user to whom the task was assigned after the action execution.
$params['log']['attach_count'] int Number of files attached during the execution of the action.
… your plugin code …

Output

Teamwork

Plugin code example

PHP

public function taskLogAdd(&$params)
{
    if (strlen(trim($params['log']['text'] ?? ''))) {
        waLog::log(
            sprintf_wp(
                "Text entered by user %s during the execution of an action on task #%d:\n%s",
                wa()->getUser()->getName(),
                $params['task']['id'],
                $params['log']['text']
            ),
            sprintf('tasks/plugins/%s/task_log_add.log', $this->id)
        );
    }
}