Filter uncanny-automator

uap_option_all_ec_events

Filters the array of all Event Espresso events available for import into Ultimate Affiliate Pro.

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

Description

Filters the available event ticket option codes for automations. Developers can use this to add custom event ticket fields or modify existing ones, controlling which event data is available for triggers and actions within Uncanny Automator.


Usage

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

Parameters

$option (mixed)
This parameter contains the selected event ticket option, which can be a single event or a group of events.

Return Value

The filtered value.


Examples

// Modify the available Uncanny Automator Event Tickets options for a specific recipe.
add_filter( 'uap_option_all_ec_events', 'my_custom_event_tickets_options', 10, 1 );

function my_custom_event_tickets_options( $option ) {

	// Assume $option is an array that looks something like this initially:
	// $option = array(
	//     'event_tickets' => array(
	//         'option_group' => 'Event Tickets',
	//         'options' => array(
	//             'EVENT_ID' => esc_attr__( 'Event ID', 'uncanny-automator' ),
	//             'EVENT_URL' => esc_attr__( 'Event URL', 'uncanny-automator' ),
	//             'EVENT_THUMB_ID' => esc_attr__( 'Event featured image ID', 'uncanny-automator' ),
	//             'EVENT_THUMB_URL' => esc_attr__( 'Event featured image URL', 'uncanny-automator' ),
	//         ),
	//     ),
	// );

	// Example: Add a new option to display the event date.
	// We'll assume the key for the new option is 'EVENT_DATE'.
	if ( isset( $option['event_tickets']['options'] ) ) {
		$option['event_tickets']['options']['EVENT_DATE'] = esc_attr__( 'Event Date', 'uncanny-automator' );
	}

	// Example: Remove an existing option, for instance, the featured image URL.
	if ( isset( $option['event_tickets']['options']['EVENT_THUMB_URL'] ) ) {
		unset( $option['event_tickets']['options']['EVENT_THUMB_URL'] );
	}

	// Return the modified options array.
	return $option;
}

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/event-tickets/helpers/event-tickets-helpers.php:241
src/integrations/event-tickets/helpers/event-tickets-helpers.php:298
uncanny-automator-pro/src/integrations/event-tickets/helpers/event-tickets-pro-helpers.php:126

public function all_ec_events( $label = null, $option_code = 'ECEVENTS', $extra_args = array() ) {

		if ( ! $label ) {
			$label = esc_attr__( 'Event', 'uncanny-automator' );
		}

		$is_ajax      = key_exists( 'is_ajax', $extra_args ) ? $extra_args['is_ajax'] : false;
		$target_field = key_exists( 'target_field', $extra_args ) ? $extra_args['target_field'] : '';
		$end_point    = key_exists( 'endpoint', $extra_args ) ? $extra_args['endpoint'] : '';

		$args = array(
			'posts_per_page' => 9999,
			'orderby'        => 'title',
			'order'          => 'DESC',
			'post_type'      => 'tribe_events',
			'post_status'    => 'publish',
		);

		$all_events = Automator()->helpers->recipe->options->wp_query( $args, true, esc_html__( 'Any event', 'uncanny-automator' ) );

		$option = array(
			'option_code'     => $option_code,
			'label'           => $label,
			'input_type'      => 'select',
			'required'        => true,
			'is_ajax'         => $is_ajax,
			'fill_values_in'  => $target_field,
			'endpoint'        => $end_point,
			//'default_value'      => 'Any post',
			'options'         => $all_events,
			'relevant_tokens' => array(
				$option_code                => esc_attr__( 'Event title', 'uncanny-automator' ),
				$option_code . '_ID'        => esc_attr__( 'Event ID', 'uncanny-automator' ),
				$option_code . '_URL'       => esc_attr__( 'Event URL', 'uncanny-automator' ),
				$option_code . '_THUMB_ID'  => esc_attr__( 'Event featured image ID', 'uncanny-automator' ),
				$option_code . '_THUMB_URL' => esc_attr__( 'Event featured image URL', 'uncanny-automator' ),
			),
		);

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

Scroll to Top