automator_asana_task_custom_field_changed
Fires when an Asana task's custom field is changed within the Automator integration.
add_action( 'automator_asana_task_custom_field_changed', $callback, 10, 3 );
Description
Fires when a custom field in an Asana task is updated. Developers can use this action hook to trigger custom automations based on specific Asana custom field changes, allowing for dynamic workflows and integrations. It is specifically designed for scenarios where only custom field modifications within a task should activate an automation.
Usage
add_action( 'automator_asana_task_custom_field_changed', 'your_function_name', 10, 3 );
Parameters
-
$this(mixed) - This parameter likely represents the current object instance of the Asana webhook processor.
-
$event_data(mixed) - This parameter likely holds an instance of the Asana webhook processor class itself, providing access to its properties and methods.
-
$event(mixed) - This parameter contains the data associated with the Asana event that triggered the webhook.
Examples
// Hook into the Asana custom field change action to log the event data.
add_action( 'automator_asana_task_custom_field_changed', 'my_log_asana_custom_field_change', 10, 3 );
/**
* Logs details when an Asana task's custom field is changed.
*
* @param int $project_config_id The ID of the project configuration.
* @param array $event_data The data associated with the Asana event.
* @param object $event The event object.
*/
function my_log_asana_custom_field_change( $project_config_id, $event_data, $event ) {
// In a real-world scenario, you might:
// 1. Update a custom post type with the change details.
// 2. Send a notification to a specific user or team.
// 3. Trigger another automation based on the specific custom field and its new value.
// For this example, we'll simply log the relevant information to the WordPress debug log.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( sprintf(
'Asana Custom Field Changed: Project Config ID: %d, Task ID: %s, Custom Fields: %s',
$project_config_id,
$event_data['gid'] ?? 'N/A', // Assuming 'gid' is the task ID
json_encode( $event_data['custom_fields'] ?? [] )
) );
}
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/asana/helpers/asana-webhook-processor.php:361
private function fire_triggers( $event_type, $event_data, $event ) {
$action_name = 'automator_asana_' . str_replace( '.', '_', $event_type );
// Fire the main trigger.
do_action( $action_name, $this->project_config['id'], $event_data, $event );
// Also fire custom field trigger if this is a custom field change.
if ( 'task.changed' === $event_type && ! empty( $event_data['custom_fields'] ) ) {
do_action( 'automator_asana_task_custom_field_changed', $this->project_config['id'], $event_data, $event );
}
}
Internal Usage
Found in uncanny-automator-pro/src/integrations/asana/triggers/task-custom-field-changed.php:65:
$this->add_action( 'automator_asana_task_custom_field_changed' );