automator_app_integration_initialized_{dynamic}
> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Add action to allow for integration-specific setup. Fires after an app integration is initialized, allowing for integration-specific setup.
add_action( 'automator_app_integration_initialized_{dynamic}', $callback, 10, 1 );
Description
Fires after an app integration is initialized. Developers can hook into this dynamic action to perform integration-specific setup or registration tasks after an app integration instance has been created and prepared. The hook name includes the integration's slug, for example, `automator_app_integration_initialized_google_sheets`.
Usage
add_action( 'automator_app_integration_initialized_{dynamic}', 'your_function_name', 10, 1 );
Parameters
-
$integration(App_Integration) - The app integration instance.
Examples
add_action( 'automator_app_integration_initialized_google_sheets', 'my_custom_google_sheets_integration_setup', 10, 1 );
/**
* Sets up custom actions and filters for the Google Sheets integration.
*
* This function is triggered after the Google Sheets app integration has been initialized.
* It can be used to register custom field mappings, conditional logic, or other
* integration-specific behaviors.
*
* @param App_Integration $integration The Google Sheets app integration instance.
*/
function my_custom_google_sheets_integration_setup( App_Integration $integration ) {
// Example: Register a custom field mapping for a specific trigger.
// Assume $integration has a method like add_custom_field_mapping()
if ( method_exists( $integration, 'add_custom_field_mapping' ) ) {
$integration->add_custom_field_mapping(
'my_custom_trigger_slug', // Slug of a custom trigger
'google_sheet_column_a', // Google Sheet column name or ID
'custom_field_key_for_trigger_data' // Key of the field within the trigger data
);
}
// Example: Add a filter to modify data before sending to Google Sheets.
// This filter would be defined elsewhere and named something like
// 'automator_app_integration_data_to_google_sheets_row'
//
// add_filter( 'automator_app_integration_data_to_google_sheets_row', function( $row_data, $integration_instance ) {
// if ( $integration_instance->get_integration() === 'google_sheets' ) {
// // Modify $row_data here before it's sent to Google Sheets
// $row_data['some_column'] = strtoupper( $row_data['some_column'] );
// }
// return $row_data;
// }, 10, 2 );
// Example: Log that the integration setup has started.
error_log( 'Custom setup for Google Sheets integration initiated.' );
}
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
src/core/lib/app-integrations/abstract-app-integration.php:167
protected function initialize_app_integration() {
// Check and set the connected status using the is_app_connected method.
$this->set_connected( $this->is_app_connected() );
// Set the settings URL.
$this->set_settings_url(
automator_get_premium_integrations_settings_url(
$this->get_settings_id()
)
);
// Set core dependencies by creating instances directly.
$this->set_dependency( 'helpers', $this->helpers );
$this->set_dependency( 'api', $this->get_api_instance() );
$this->set_dependency( 'webhooks', $this->get_webhooks_instance() );
// Pass dependencies to helpers.
$this->helpers->set_dependencies( $this->dependencies );
// Pass dependencies to api.
if ( $this->dependencies->api ) {
$this->dependencies->api->set_dependencies( $this->dependencies );
}
// Pass dependencies to webhooks.
if ( $this->dependencies->webhooks ) {
$this->dependencies->webhooks->set_dependencies( $this->dependencies );
}
// Allow child classes to register custom dependencies.
$this->register_dependencies();
// Initialize webhooks if they exist and integration is connected.
if ( ! is_null( $this->dependencies->webhooks ) && $this->get_connected() ) {
$this->dependencies->webhooks->initialize();
}
// Register integration-specific hooks
$this->register_hooks();
/**
* Add action to allow for integration-specific setup.
*
* @param App_Integration $integration The app integration instance.
*/
do_action( 'automator_app_integration_initialized_' . $this->get_integration(), $this );
}