Filter uncanny-automator

uap_option_wp_fusion_tags

Filters the available WP Fusion tags to customize which tags are displayed in the Uni AP settings.

add_filter( 'uap_option_wp_fusion_tags', $callback, 10, 1 );

Description

Fires when generating options for the WP Fusion tags field. Developers can use this filter to modify the available options, add new ones, or remove existing ones, allowing for custom WP Fusion tag integration within Uncanny Automator recipes. The `$option` parameter contains the field configuration.


Usage

add_filter( 'uap_option_wp_fusion_tags', 'your_function_name', 10, 1 );

Parameters

$option (mixed)
This parameter holds the current value of the option being filtered, which by default is an empty array and is populated with available WP Fusion tags.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to filter the 'uap_option_wp_fusion_tags' hook
 * to add or modify available tags for WP Fusion in Uncanny Automator Pro.
 *
 * In this example, we'll add a custom tag for users who have completed a specific course.
 */
add_filter( 'uap_option_wp_fusion_tags', function( $option ) {

	// Check if the current option being processed is the one related to user course completion.
	// This is a hypothetical check. In a real scenario, you'd need to inspect $option['option_code']
	// or other properties to identify the correct tag set you want to modify.
	// For demonstration, let's assume we want to add to a tag list that might be related to user progress.
	if ( isset( $option['option_code'] ) && $option['option_code'] === 'user_course_progress' ) {

		// Define our new custom tag.
		$custom_tag = array(
			'value' => 'course_completed_advanced_course',
			'label' => __( 'Completed Advanced Course', 'your-text-domain' ),
		);

		// Add the custom tag to the existing options.
		// We'll prepend it for this example.
		if ( isset( $option['options'] ) && is_array( $option['options'] ) ) {
			array_unshift( $option['options'], $custom_tag );
		} else {
			// If there are no options yet, initialize the array with our custom tag.
			$option['options'] = array( $custom_tag );
		}
	}

	// It's crucial to return the modified $option array.
	return $option;

}, 10, 1 ); // Priority 10, accepts 1 argument.
?>

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/integrations/wp-fusion/helpers/wp-fusion-helpers.php:84
uncanny-automator-pro/src/integrations/wp-fusion/helpers/wp-fusion-pro-helpers.php:79

public static function fusion_tags( $label = '', $trigger_meta = '' ) {

		if ( empty( $label ) ) {
			$label = esc_html__( 'Tag', 'uncanny-automator' );
		}

		$tags    = wp_fusion()->settings->get( 'available_tags' );
		$options = array();
		if ( $tags ) {
			foreach ( $tags as $t_id => $tag ) {
				if ( is_array( $tag ) && isset( $tag['label'] ) ) {
					$options[ $t_id ] = $tag['label'];
				} else {
					$options[ $t_id ] = $tag;
				}
			}
		}

		$option = array(
			'option_code' => $trigger_meta,
			'label'       => $label,
			'input_type'  => 'select',
			'required'    => true,
			'options'     => $options,
		);

		return apply_filters( 'uap_option_wp_fusion_tags', $option );
	}

Scroll to Top