Filter uncanny-automator

automator_give_wp_form_field

Filters fields for GiveWP form fields before they are displayed or processed by Automator.

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

Description

Filters the fields array for GiveWP form selections in Uncanny Automator. Developers can use this to modify or add to the list of available form fields that can be used in Automator recipes. This hook fires when Uncanny Automator retrieves and processes GiveWP form data for integration.


Usage

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

Parameters

$fields (mixed)
This parameter contains an array of fields from the GiveWP form builder.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the automator_give_wp_form_field filter to modify GiveWP form fields.
 * This example adds a custom 'hidden' field type if a specific field is found in the form.
 */
add_filter( 'automator_give_wp_form_field', 'my_custom_give_wp_form_field_modifier', 10, 1 );

/**
 * Modifies GiveWP form fields for Uncanny Automator.
 *
 * This function checks if a 'donation_amount' field exists and, if so,
 * adds a new 'hidden' field with a specific value.
 *
 * @param array $fields An array of form fields extracted from GiveWP.
 * @return array The modified array of form fields.
 */
function my_custom_give_wp_form_field_modifier( $fields ) {
	// Check if the 'donation_amount' field exists in the current form.
	$donation_amount_found = false;
	foreach ( $fields as $field_key => $field_data ) {
		if ( isset( $field_data['fieldName'] ) && 'donation_amount' === $field_data['fieldName'] ) {
			$donation_amount_found = true;
			break; // No need to continue searching once found.
		}
	}

	// If the donation amount field was found, add a custom hidden field.
	if ( $donation_amount_found ) {
		$fields[] = array(
			'label'     => 'Custom Donation Reference',
			'type'      => 'hidden', // 'hidden' is a custom type we might be supporting.
			'fieldName' => 'custom_donation_ref',
			'value'     => 'AUTOMATOR-' . uniqid(), // A unique reference for automation.
			'custom'    => true, // Mark as custom to be handled by the plugin.
		);
	}

	return $fields;
}

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/give/helpers/give-helpers.php:216
uncanny-automator-pro/src/integrations/give/helpers/give-pro-helpers.php:125

'custom'   => true,
						);
					}
				}
			}
		}

		return apply_filters( 'automator_give_wp_form_field', $fields );
	}

	/**
	 * Extract field labels and types from GiveWP v3 form builder data.
	 *
	 * @param array|string $form_builder_data JSON string or decoded array of form builder blocks.
	 * @return array Array of fields with label, type, fieldName, and other metadata.


Scroll to Top