Filter uncanny-automator

automator_wpforms_disallowed_fields

Filters disallowed WPForms fields for Automator actions, allowing customization of form submissions.

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

Description

Filters the array of WPForms field types that Uncanny Automator cannot use for tokens. This allows developers to prevent specific fields from being available as token options. It fires when the list of disallowed field types is being constructed.


Usage

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

Parameters

$form_ids (mixed)
This parameter contains an array of WPForms field types that are intentionally excluded from being used as tokens in Uncanny Automator recipes.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of filtering disallowed WPForms field types for Uncanny Automator.
 * This function might be used to add or remove certain field types from
 * being available as tokens in Uncanny Automator for WPForms integrations.
 * For instance, a developer might want to exclude custom fields added by
 * another plugin that don't have a direct token representation.
 */
add_filter(
	'automator_wpforms_disallowed_fields',
	function ( $disallowed_field_types, $form_ids ) {
		// Example: If we want to allow 'html' fields for a specific form ID
		// (assuming $form_ids is the ID of the form being processed).
		// In a real scenario, $form_ids might be an array or a single ID.
		// For this example, let's assume it's a single form ID.
		$specific_form_id_to_allow_html = 123; // Replace with an actual form ID

		if ( is_array( $form_ids ) && in_array( $specific_form_id_to_allow_html, $form_ids ) ) {
			// Remove 'html' from the disallowed list for this specific form.
			$disallowed_field_types = array_diff( $disallowed_field_types, array( 'html' ) );
		} elseif ( ! is_array( $form_ids ) && $form_ids === $specific_form_id_to_allow_html ) {
			// Handle the case where $form_ids is not an array.
			$disallowed_field_types = array_diff( $disallowed_field_types, array( 'html' ) );
		}

		// Example: Add a hypothetical custom field type that shouldn't be a token.
		// Let's say another plugin adds a field type called 'my-custom-rating'.
		// $disallowed_field_types[] = 'my-custom-rating';

		return $disallowed_field_types;
	},
	10, // Priority: 10 is the default.
	2   // Accepted args: The filter accepts two arguments: $disallowed_field_types and $form_ids.
);

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/wpforms/tokens/wpf-tokens.php:73
uncanny-automator-pro/src/integrations/wpforms/helpers/wpforms-pro-helpers.php:45

'email',
			'float',
			'int',
			'text',
			'file-upload',
		);

		$disallowed_field_types = apply_filters(
			'automator_wpforms_disallowed_fields',
			array(
				'pagebreak',
				'password',
				'divider',
				'entry-preview',
				'html',

Scroll to Top