Filter uncanny-automator

automator_register_trigger_integration

Filters trigger integrations to be registered within Automator for core functionality.

add_filter( 'automator_register_trigger_integration', $callback, 10, 3 );

Description

Filters the trigger integration definition before it's registered. Developers can modify the integration array to alter trigger properties, add custom fields, or adjust default settings. This hook fires during the integration registration process, allowing fine-grained control over how triggers are presented and function within the plugin.


Usage

add_filter( 'automator_register_trigger_integration', 'your_function_name', 10, 3 );

Parameters

$integration (mixed)
This parameter contains the integration object itself, which is being registered for a trigger.
$trigger (mixed)
This parameter contains information about the specific integration being registered.
$integration_code (mixed)
This parameter holds the trigger object that is being registered.

Return Value

The filtered value.


Examples

/**
 * Example of how to hook into the 'automator_register_trigger_integration' filter.
 *
 * This filter allows you to modify the integration data before it's registered
 * for a specific trigger. In this example, we'll conditionally add a new meta key
 * to the integration data based on the trigger's code.
 *
 * @param mixed  $integration       The integration data. Can be any type, but often an array or object.
 * @param mixed  $trigger           The trigger data.
 * @param string $integration_code The unique code identifying the integration.
 *
 * @return mixed The modified integration data.
 */
add_filter( 'automator_register_trigger_integration', function( $integration, $trigger, $integration_code ) {

	// Example: If the trigger code is 'new_post_published', add a specific meta key.
	if ( 'new_post_published' === $integration_code ) {
		// Assuming $integration is an array. If it's an object, adjust accordingly.
		if ( is_array( $integration ) ) {
			$integration['custom_meta_for_posts'] = 'This is a special meta value for new post triggers.';
		} elseif ( is_object( $integration ) ) {
			$integration->custom_meta_for_posts = 'This is a special meta value for new post triggers.';
		}
	}

	// Always return the integration data, whether modified or not.
	return $integration;

}, 10, 3 );

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/utilities/class-automator-registration.php:183

*/
		$integration = apply_filters_deprecated(
			'uap_register_trigger_integration',
			array( $integration, $trigger, $integration_code ),
			'3.0',
			'automator_register_trigger_integration'
		);
		$integration = apply_filters( 'automator_register_trigger_integration', $integration, $trigger, $integration_code );
		//      $integrations = Automator()->get_integrations();
		// Integration was passed in, lets try to register it
		if ( null !== $integration_code ) {
			if ( ! is_string( $integration_code ) || null === $integration || is_array( $integration ) ) {
				throw new Automator_Exception( 'You are trying to register a trigger without passing integration code.', 1001 );
			}


Scroll to Top