[Documentation](https://groundhogg.io/documentation/) » [Classes](https://groundhogg.io/documentation/#doc-classes)

# \Groundhogg\Classes\Task

Published Tuesday, June 9, 2026 · Last updated Tuesday, June 9, 2026

extends `Note`

Represents a CRM task — a to-do item associated with a contact or other object. Tasks extend `Note` with a due date and completion state. They appear in the contact record and the tasks dashboard.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| `complete()` | `bool` | Marks the task as complete and records the completion timestamp. |
| `incomplete()` | `bool` | Marks the task as incomplete. |
| `is_complete()` | `bool` | Returns `true` if the task has been marked complete. |
| `is_overdue()` | `bool` | Returns `true` if the due date has passed and the task is not complete. |
| `is_due_today()` | `bool` | Returns `true` if the task is due today. |
| `is_due_soon()` | `bool` | Returns `true` if the task is due within the configured threshold. |
| `days_till_due()` | `int` | Returns the number of days until the task is due. |
| `get_due_date()` | `string` | Returns the due date as a formatted string. |
| `get_date_completed()` | `string` | Returns the completion date as a formatted string. |
| `is_for_contact()` | `bool` | Returns `true` if the task is associated with a contact. |
| `get_associated_data()` | `array` | Returns the data of the object this task is associated with. |

## Usage

Here’s a pseudo code example for a hypothetical CRM task automation integration.

```

<?php

add_action( 'groundhogg/contact/tag_applied', 'my_plugin_create_follow_up_task', 10, 2 );

/**
 * Create a follow-up task when the "hot-lead" tag is applied.
 *
 * @param \Groundhogg\Contact $contact
 * @param int                  $tag_id
 *
 * @return void
 */
function my_plugin_create_follow_up_task( $contact, $tag_id ) {

    if ( $tag_id !== MY_PLUGIN_HOT_LEAD_TAG_ID ) {
        return;
    }

    $task = new \Groundhogg\Classes\Task( [
        'object_id'   => $contact->get_id(),
        'object_type' => 'contact',
        'user_id'     => $contact->get_owner_id(),
        'content'     => 'Follow up with ' . $contact->get_full_name(),
        'due_date'    => date( 'Y-m-d', strtotime( '+1 day' ) ),
    ] );

    $task->create();
}
```
