Using Gravity Forms ‘gform_capsulecrm_task’ PHP filter

The gform_capsulecrm_task filter allows you to modify the Capsule CRM Task object before it is created in Gravity Forms.

Usage

A generic example of how to use the filter:

add_filter('gform_capsulecrm_task', 'your_function_name', 10, 4);

Target a specific form by appending the form ID to the hook name:

add_filter('gform_capsulecrm_task_1', 'your_function_name', 10, 4);

Target a specific feed for a form by appending the form ID and feed ID to the hook name:

add_filter('gform_capsulecrm_task_1_7', 'your_function_name', 10, 4);

Parameters

  • $task (array): The Capsule CRM task object.
  • $form (Form Object): The current form.
  • $entry (Entry Object): The current entry.
  • $feed (Feed Object): The current feed.

More information

See Gravity Forms Docs: gform_capsulecrm_task

Examples

Change Task Description

This example modifies the task description:

add_filter('gform_capsulecrm_task', 'change_task_object', 10, 4);

function change_task_object($task, $form, $entry, $feed) {
    $task['description'] = 'Task Created by API';
    return $task;
}

Set Task Owner

This example sets the task owner based on the entry data:

add_filter('gform_capsulecrm_task', 'set_task_owner', 10, 4);

function set_task_owner($task, $form, $entry, $feed) {
    $task['owner'] = array('username' => $entry['1']);
    return $task;
}

Modify Task Due Date

This example changes the task due date based on the form entry:

add_filter('gform_capsulecrm_task', 'modify_task_due_date', 10, 4);

function modify_task_due_date($task, $form, $entry, $feed) {
    $task['dueOn'] = date('Y-m-d', strtotime($entry['2']));
    return $task;
}

Change Task Category

This example sets the task category based on the form entry:

add_filter('gform_capsulecrm_task', 'change_task_category', 10, 4);

function change_task_category($task, $form, $entry, $feed) {
    $task['category'] = array('name' => $entry['3']);
    return $task;
}

Modify Task Status

This example sets the task status based on the form entry:

add_filter('gform_capsulecrm_task', 'modify_task_status', 10, 4);

function modify_task_status($task, $form, $entry, $feed) {
    $task['status'] = $entry['4'] == '1' ? 'OPEN' : 'CLOSED';
    return $task;
}

Place the code in the functions.php file of your active theme.